From 9a78c8bd31255627151c44fb07deec7d0cf159ad Mon Sep 17 00:00:00 2001 From: Danil Alexeev Date: Tue, 10 Dec 2024 13:12:33 +0300 Subject: [PATCH] GDScript: Group similar analyzer/runtime error tests into single files --- modules/gdscript/gdscript_analyzer.cpp | 8 +- .../gdscript/tests/gdscript_test_runner.cpp | 14 +- .../errors/abstract_class_instantiate.out | 5 - .../analyzer/errors/abstract_methods.out | 10 +- .../analyzer/errors/assign_constant.gd | 14 ++ .../analyzer/errors/assign_constant.out | 6 + .../scripts/analyzer/errors/assign_enum.gd | 3 - .../scripts/analyzer/errors/assign_enum.out | 2 - .../analyzer/errors/assign_named_enum.gd | 3 - .../analyzer/errors/assign_named_enum.out | 2 - .../scripts/analyzer/errors/assign_signal.gd | 4 - .../scripts/analyzer/errors/assign_signal.out | 2 - .../errors/assign_to_read_only_property.gd | 6 + .../errors/assign_to_read_only_property.out | 3 +- ...assign_to_read_only_property_indirectly.gd | 4 - ...ssign_to_read_only_property_indirectly.out | 2 - ...nt_bad.gd => asymmetric_assignment_bad.gd} | 0 ..._bad.out => asymmetric_assignment_bad.out} | 0 ...float_left_operand.gd => bitwise_float.gd} | 2 +- ...at_right_operand.out => bitwise_float.out} | 1 + .../errors/bitwise_float_left_operand.out | 2 - .../errors/bitwise_float_right_operand.gd | 3 - .../analyzer/errors/cast_int_to_array.gd | 3 - .../analyzer/errors/cast_int_to_array.out | 2 - .../analyzer/errors/cast_int_to_object.gd | 3 - .../analyzer/errors/cast_int_to_object.out | 2 - .../analyzer/errors/cast_object_to_int.out | 2 - .../errors/class_name_shadows_builtin_type.gd | 5 - .../class_name_shadows_builtin_type.out | 2 - .../errors/constant_array_index_assign.gd | 5 - .../errors/constant_array_index_assign.out | 2 - .../analyzer/errors/constant_collections.gd | 7 + ..._property.out => constant_collections.out} | 1 + .../constant_dictionary_index_assign.gd | 5 - .../constant_dictionary_index_assign.out | 2 - .../constant_name_shadows_builtin_type.gd | 4 - .../constant_name_shadows_builtin_type.out | 2 - .../errors/constant_used_as_function.gd | 5 - .../errors/constant_used_as_function.out | 3 - .../analyzer/errors/cyclic_inheritance.gd | 8 - .../analyzer/errors/cyclic_inheritance.out | 2 - .../analyzer/errors/cyclic_ref_const.gd | 5 - .../analyzer/errors/cyclic_ref_const.out | 3 - .../analyzer/errors/cyclic_ref_enum.gd | 5 - .../analyzer/errors/cyclic_ref_enum.out | 3 - .../analyzer/errors/cyclic_ref_enum_value.gd | 5 - .../analyzer/errors/cyclic_ref_enum_value.out | 2 - .../analyzer/errors/cyclic_ref_external.gd | 6 - .../analyzer/errors/cyclic_ref_external.out | 3 - .../errors/cyclic_ref_external_a.notest.gd | 5 - .../analyzer/errors/cyclic_ref_func.gd | 9 -- .../analyzer/errors/cyclic_ref_func.out | 3 - .../analyzer/errors/cyclic_ref_override.gd | 12 -- .../analyzer/errors/cyclic_ref_override.out | 2 - .../scripts/analyzer/errors/cyclic_ref_var.gd | 5 - .../analyzer/errors/cyclic_ref_var.out | 3 - .../analyzer/errors/cyclic_ref_var_self.gd | 4 - .../analyzer/errors/cyclic_ref_var_self.out | 3 - .../analyzer/errors/cyclic_reference.gd | 41 +++++ .../errors/cyclic_reference.notest.gd | 5 + .../analyzer/errors/cyclic_reference.out | 27 ++++ .../errors/dictionary_duplicate_key.gd | 16 ++ .../errors/dictionary_duplicate_key.out | 4 + .../errors/dictionary_duplicate_key_lua.gd | 6 - .../errors/dictionary_duplicate_key_lua.out | 2 - ...ictionary_duplicate_key_lua_with_string.gd | 6 - ...ctionary_duplicate_key_lua_with_string.out | 2 - .../errors/dictionary_duplicate_key_python.gd | 6 - .../dictionary_duplicate_key_python.out | 2 - .../errors/engine_singleton_instantiate.gd | 2 - .../errors/engine_singleton_instantiate.out | 2 - .../analyzer/errors/enum_bad_method.gd | 4 - .../analyzer/errors/enum_bad_method.out | 2 - .../scripts/analyzer/errors/enum_bad_value.gd | 4 - .../analyzer/errors/enum_bad_value.out | 2 - .../analyzer/errors/enum_builtin_access.gd | 2 - .../analyzer/errors/enum_builtin_access.out | 2 - ...m_class_var_assign_with_wrong_enum_type.gd | 10 -- ..._class_var_assign_with_wrong_enum_type.out | 3 - ...num_class_var_init_with_wrong_enum_type.gd | 8 - ...um_class_var_init_with_wrong_enum_type.out | 3 - .../errors/enum_declaration_and_usage.gd | 28 ++++ .../errors/enum_declaration_and_usage.out | 30 ++++ .../errors/enum_duplicate_bad_method.gd | 5 - .../errors/enum_duplicate_bad_method.out | 2 - .../analyzer/errors/enum_float_value.gd | 7 - .../analyzer/errors/enum_float_value.out | 2 - .../enum_function_parameter_wrong_type.gd | 8 - .../enum_function_parameter_wrong_type.out | 3 - .../errors/enum_function_return_wrong_type.gd | 8 - .../enum_function_return_wrong_type.out | 3 - .../analyzer/errors/enum_global_access.gd | 2 - .../analyzer/errors/enum_global_access.out | 2 - ...l_var_assign_outer_with_wrong_enum_type.gd | 10 -- ..._var_assign_outer_with_wrong_enum_type.out | 3 - ...m_local_var_assign_with_wrong_enum_type.gd | 8 - ..._local_var_assign_with_wrong_enum_type.out | 3 - ...num_local_var_init_with_wrong_enum_type.gd | 6 - ...um_local_var_init_with_wrong_enum_type.out | 3 - .../errors/enum_name_shadows_builtin_type.gd | 4 - .../errors/enum_name_shadows_builtin_type.out | 2 - .../analyzer/errors/enum_native_access.gd | 2 - .../analyzer/errors/enum_native_access.out | 2 - .../analyzer/errors/enum_native_bad_value.gd | 2 - .../analyzer/errors/enum_native_bad_value.out | 2 - .../enum_preload_unnamed_assign_to_named.gd | 7 - .../enum_preload_unnamed_assign_to_named.out | 3 - .../analyzer/errors/enum_shadows_base_enum.gd | 8 - .../errors/enum_shadows_base_enum.out | 2 - .../analyzer/errors/enum_string_value.gd | 7 - .../analyzer/errors/enum_string_value.out | 2 - .../analyzer/errors/enum_type_checking.gd | 39 +++++ .../analyzer/errors/enum_type_checking.out | 21 +++ .../errors/enum_unnamed_assign_to_named.gd | 7 - .../errors/enum_unnamed_assign_to_named.out | 3 - .../export_node_in_non_node_derived_class.gd | 10 ++ .../export_node_in_non_node_derived_class.out | 3 + ...export_node_in_non_node_derived_class_1.gd | 8 - ...xport_node_in_non_node_derived_class_1.out | 2 - ...export_node_in_non_node_derived_class_2.gd | 9 -- ...xport_node_in_non_node_derived_class_2.out | 2 - ...export_node_in_non_node_derived_class_3.gd | 8 - ...xport_node_in_non_node_derived_class_3.out | 2 - .../errors/extend_engine_singleton.gd | 6 - .../errors/extend_engine_singleton.out | 2 - .../errors/extend_non_class_constant_1.gd | 9 -- .../errors/extend_non_class_constant_1.out | 2 - .../errors/extend_non_class_constant_2.gd | 12 -- .../errors/extend_non_class_constant_2.out | 2 - .../errors/extend_non_gdscript_nested.gd | 5 - .../errors/extend_non_gdscript_nested.out | 2 - .../scripts/analyzer/errors/extend_unknown.gd | 8 - .../analyzer/errors/extend_unknown.out | 2 - .../analyzer/errors/extend_variable.gd | 9 -- .../analyzer/errors/extend_variable.out | 2 - .../analyzer/errors/for_loop_inferred_type.gd | 59 +++++++ .../errors/for_loop_inferred_type.out | 10 ++ .../errors/for_loop_on_constant_float.gd | 6 - .../errors/for_loop_on_constant_float.out | 2 - .../errors/for_loop_on_constant_int.gd | 6 - .../errors/for_loop_on_constant_int.out | 2 - .../analyzer/errors/for_loop_on_enum_value.gd | 6 - .../errors/for_loop_on_enum_value.out | 2 - .../analyzer/errors/for_loop_on_hard_float.gd | 6 - .../errors/for_loop_on_hard_float.out | 2 - .../analyzer/errors/for_loop_on_hard_int.gd | 6 - .../analyzer/errors/for_loop_on_hard_int.out | 2 - .../errors/for_loop_on_hard_iterator.gd | 14 -- .../errors/for_loop_on_hard_iterator.out | 2 - .../errors/for_loop_on_hard_string.gd | 6 - .../errors/for_loop_on_hard_string.out | 2 - .../errors/for_loop_on_literal_bool.gd | 3 - .../errors/for_loop_on_literal_bool.out | 2 - .../errors/for_loop_on_literal_int.gd | 4 - .../errors/for_loop_on_literal_int.out | 2 - .../errors/for_loop_wrong_specified_type.gd | 7 + .../errors/for_loop_wrong_specified_type.out | 4 + ...wrong_specified_type_with_literal_array.gd | 5 - ...rong_specified_type_with_literal_array.out | 3 - ..._specified_type_with_literal_dictionary.gd | 3 - ...specified_type_with_literal_dictionary.out | 3 - ...h_parent_signature_parameter_count_less.gd | 10 -- ..._parent_signature_parameter_count_less.out | 2 - ...h_parent_signature_parameter_count_more.gd | 10 -- ..._parent_signature_parameter_count_more.out | 2 - ...rent_signature_parameter_default_values.gd | 10 -- ...ent_signature_parameter_default_values.out | 2 - ...t_match_parent_signature_parameter_type.gd | 10 -- ..._match_parent_signature_parameter_type.out | 2 - ...dont_match_parent_signature_return_type.gd | 10 -- ...ont_match_parent_signature_return_type.out | 2 - ...ion_param_type_invalid_contravariance_1.gd | 10 -- ...on_param_type_invalid_contravariance_1.out | 2 - ...ion_param_type_invalid_contravariance_2.gd | 10 -- ...on_param_type_invalid_contravariance_2.out | 2 - ...ion_param_type_invalid_contravariance_3.gd | 10 -- ...on_param_type_invalid_contravariance_3.out | 2 - ...nction_return_type_invalid_covariance_1.gd | 10 -- ...ction_return_type_invalid_covariance_1.out | 2 - ...nction_return_type_invalid_covariance_2.gd | 10 -- ...ction_return_type_invalid_covariance_2.out | 2 - ...nction_return_type_invalid_covariance_3.gd | 10 -- ...ction_return_type_invalid_covariance_3.out | 2 - ...nction_return_type_invalid_covariance_4.gd | 10 -- ...ction_return_type_invalid_covariance_4.out | 2 - .../function_signature_compatibility.gd | 34 ++++ .../function_signature_compatibility.out | 13 ++ .../errors/function_used_as_property.gd | 6 - .../errors/gd_utility_function_wrong_arg.gd | 2 - .../errors/gd_utility_function_wrong_arg.out | 2 - .../analyzer/errors/get_node_shorthand.gd | 11 ++ ...in_non_node.out => get_node_shorthand.out} | 4 +- .../get_node_shorthand_in_static_function.gd | 9 -- .../get_node_shorthand_in_static_function.out | 2 - .../get_node_shorthand_within_non_node.gd | 5 - .../errors/inferring_with_weak_type.gd | 9 ++ .../errors/inferring_with_weak_type.out | 4 + ...inferring_with_weak_type_local_variable.gd | 3 - ...nferring_with_weak_type_local_variable.out | 2 - ...nferring_with_weak_type_member_variable.gd | 5 - ...ferring_with_weak_type_member_variable.out | 2 - .../inferring_with_weak_type_parameter.gd | 5 - .../inferring_with_weak_type_parameter.out | 2 - ...{cast_object_to_int.gd => invalid_cast.gd} | 3 + .../scripts/analyzer/errors/invalid_cast.out | 4 + ...dictionary.gd => invalid_concatenation.gd} | 2 + .../analyzer/errors/invalid_concatenation.out | 4 + .../errors/invalid_concatenation_bool.gd | 2 - .../errors/invalid_concatenation_bool.out | 2 - .../invalid_concatenation_dictionary.out | 2 - .../errors/invalid_concatenation_mixed.gd | 2 - .../errors/invalid_concatenation_mixed.out | 2 - .../analyzer/errors/invalid_inheritance.gd | 35 +++++ .../analyzer/errors/invalid_inheritance.out | 8 + ...nstantiate.gd => invalid_instantiation.gd} | 3 +- .../analyzer/errors/invalid_instantiation.out | 6 + .../analyzer/errors/invalid_member_usage.gd | 14 ++ .../analyzer/errors/invalid_member_usage.out | 6 + .../scripts/analyzer/errors/invalid_return.gd | 22 +++ .../analyzer/errors/invalid_return.out | 8 + .../errors/lambda_cyclic_ref_call_arg.gd | 5 - .../errors/lambda_cyclic_ref_call_arg.out | 3 - .../errors/lambda_cyclic_ref_param.gd | 5 - .../errors/lambda_cyclic_ref_param.out | 3 - .../analyzer/errors/lambda_no_return.gd | 4 - .../analyzer/errors/lambda_no_return.out | 2 - .../analyzer/errors/lambda_wrong_return.gd | 4 - .../analyzer/errors/lambda_wrong_return.out | 3 - .../analyzer/errors/local_const_as_type.gd | 11 ++ .../analyzer/errors/local_const_as_type.out | 4 + ...local_const_as_type_use_before_declared.gd | 5 - ...ocal_const_as_type_use_before_declared.out | 2 - .../local_const_as_type_use_not_const.gd | 5 - .../local_const_as_type_use_not_const.out | 2 - .../local_const_as_type_use_not_type.gd | 5 - .../local_const_as_type_use_not_type.out | 2 - .../tests/scripts/analyzer/errors/match.gd | 10 ++ .../tests/scripts/analyzer/errors/match.out | 4 + .../errors/match_guard_invalid_expression.gd | 4 - .../errors/match_guard_invalid_expression.out | 2 - .../analyzer/errors/match_with_subscript.gd | 5 - .../analyzer/errors/match_with_subscript.out | 2 - .../errors/match_with_variable_expression.gd | 5 - .../errors/match_with_variable_expression.out | 2 - ...ive_type_errors.gd => not_found_member.gd} | 0 ...e_type_errors.out => not_found_member.out} | 0 .../analyzer/errors/preload_enum_error.gd | 6 - .../analyzer/errors/preload_enum_error.out | 3 - .../scripts/analyzer/errors/properties.gd | 29 ++++ .../scripts/analyzer/errors/properties.out | 6 + .../property_function_get_type_error.gd | 11 -- .../property_function_get_type_error.out | 2 - .../property_function_set_type_error.gd | 11 -- .../property_function_set_type_error.out | 2 - .../errors/property_inline_get_type_error.gd | 9 -- .../errors/property_inline_get_type_error.out | 2 - .../errors/property_inline_set_type_error.gd | 9 -- .../errors/property_inline_set_type_error.out | 2 - .../errors/property_used_as_function.gd | 4 - .../errors/property_used_as_function.out | 3 - .../errors/redefine_class_constant.gd | 7 - .../errors/redefine_class_constant.out | 2 - .../analyzer/errors/redefine_constant.gd | 9 ++ .../analyzer/errors/redefine_constant.out | 3 + .../errors/redefine_local_constant.gd | 5 - .../errors/redefine_local_constant.out | 2 - .../errors/return_null_in_void_func.gd | 2 - .../errors/return_null_in_void_func.out | 2 - .../errors/return_variant_in_void_func.gd | 4 - .../errors/return_variant_in_void_func.out | 2 - .../setter_parameter_uses_property_type.gd | 8 - .../setter_parameter_uses_property_type.out | 2 - .../scripts/analyzer/errors/shadowing.gd | 13 ++ .../scripts/analyzer/errors/shadowing.out | 6 + .../errors/static_access_non_static.gd | 78 ++++++++++ .../errors/static_access_non_static.out | 14 ++ .../static_constructor_with_return_type.gd | 5 - .../static_constructor_with_return_type.out | 2 - .../errors/static_func_access_non_static.gd | 10 -- .../errors/static_func_access_non_static.out | 2 - ..._func_access_non_static_in_lambda_param.gd | 15 -- ...func_access_non_static_in_lambda_param.out | 2 - .../errors/static_func_call_non_static.gd | 8 - .../errors/static_func_call_non_static.out | 2 - .../static_func_call_non_static_in_lambda.gd | 14 -- .../static_func_call_non_static_in_lambda.out | 2 - ...ic_func_call_non_static_in_lambda_param.gd | 15 -- ...c_func_call_non_static_in_lambda_param.out | 2 - ...ic_var_init_access_non_static_in_lambda.gd | 14 -- ...c_var_init_access_non_static_in_lambda.out | 2 - ...init_access_non_static_in_lambda_setter.gd | 15 -- ...nit_access_non_static_in_lambda_setter.out | 2 - ...atic_var_init_call_non_static_in_lambda.gd | 14 -- ...tic_var_init_call_non_static_in_lambda.out | 2 - ...r_init_call_non_static_in_lambda_setter.gd | 15 -- ..._init_call_non_static_in_lambda_setter.out | 2 - .../static_var_init_non_static_access.gd | 11 -- .../static_var_init_non_static_access.out | 2 - .../errors/static_var_init_non_static_call.gd | 9 -- .../static_var_init_non_static_call.out | 2 - .../scripts/analyzer/errors/typed_array.gd | 11 ++ .../scripts/analyzer/errors/typed_array.out | 6 + .../typed_array_assign_differently_typed.gd | 4 - .../typed_array_assign_differently_typed.out | 2 - .../analyzer/errors/typed_array_assignment.gd | 2 - .../errors/typed_array_assignment.out | 3 - ...rray_init_with_unconvertable_in_literal.gd | 4 - ...ray_init_with_unconvertable_in_literal.out | 2 - .../typed_array_pass_differently_to_typed.gd | 7 - .../typed_array_pass_differently_to_typed.out | 2 - .../analyzer/errors/typed_dictionary.gd | 11 ++ .../analyzer/errors/typed_dictionary.out | 6 + ...ped_dictionary_assign_differently_typed.gd | 4 - ...ed_dictionary_assign_differently_typed.out | 2 - .../errors/typed_dictionary_assignment.gd | 2 - .../errors/typed_dictionary_assignment.out | 3 - ...nary_init_with_unconvertible_in_literal.gd | 4 - ...ary_init_with_unconvertible_in_literal.out | 2 - ...ed_dictionary_pass_differently_to_typed.gd | 7 - ...d_dictionary_pass_differently_to_typed.out | 2 - .../errors/use_value_of_void_function.gd | 14 ++ .../errors/use_value_of_void_function.out | 6 + ...e_value_of_void_function_builtin_method.gd | 3 - ..._value_of_void_function_builtin_method.out | 2 - ...se_value_of_void_function_custom_method.gd | 5 - ...e_value_of_void_function_custom_method.out | 2 - .../use_value_of_void_function_gd_utility.gd | 2 - .../use_value_of_void_function_gd_utility.out | 2 - ...se_value_of_void_function_native_method.gd | 3 - ...e_value_of_void_function_native_method.out | 2 - .../use_value_of_void_function_utility.gd | 2 - .../use_value_of_void_function_utility.out | 2 - ...tion_wrong_arg.gd => utility_functions.gd} | 1 + ...on_wrong_arg.out => utility_functions.out} | 1 + .../variable_name_shadows_builtin_type.gd | 4 - .../variable_name_shadows_builtin_type.out | 2 - .../analyzer/errors/variadic_functions.out | 4 +- .../analyzer/features/constant_expressions.gd | 2 +- .../features/export_enum_as_dictionary.gd | 2 +- .../global_builtin_and_native_enums.gd | 2 +- .../warnings/{shadowning.gd => shadowing.gd} | 0 .../{shadowning.out => shadowing.out} | 2 +- .../warnings/shadowing_base.notest.gd | 2 +- .../scripts/parser/features/annotations.gd | 2 +- .../scripts/parser/features/export_arrays.gd | 2 +- .../scripts/parser/features/export_enum.gd | 2 +- .../parser/features/export_variable.gd | 2 +- .../parser/features/multiline_preload.gd | 15 ++ .../parser/features/multiline_preload.out | 2 + .../runtime/errors/assign_freed_instance.gd | 6 +- .../runtime/errors/assign_freed_instance.out | 4 +- .../errors/assign_to_read_only_property.gd | 2 + .../errors/assign_to_read_only_property.out | 6 +- .../errors/callable_call_after_free_object.gd | 1 + .../runtime/errors/cast_freed_object.gd | 4 - .../runtime/errors/cast_freed_object.out | 2 - .../runtime/errors/cast_int_to_array.gd | 4 - .../runtime/errors/cast_int_to_array.out | 2 - .../runtime/errors/cast_int_to_object.gd | 4 - .../runtime/errors/cast_int_to_object.out | 2 - .../runtime/errors/cast_object_to_int.gd | 4 - .../runtime/errors/cast_object_to_int.out | 2 - .../runtime/errors/constant_array_is_deep.gd | 6 - .../runtime/errors/constant_array_is_deep.out | 4 - .../runtime/errors/constant_collections.gd | 32 ++++ .../runtime/errors/constant_collections.out | 9 ++ .../errors/constant_dictionary_is_deep.gd | 6 - .../errors/constant_dictionary_is_deep.out | 2 - .../runtime/errors/division_by_zero.gd | 44 +++++- .../runtime/errors/division_by_zero.out | 9 +- .../errors/gd_utility_function_wrong_arg.gd | 3 - .../errors/gd_utility_function_wrong_arg.out | 2 - .../scripts/runtime/errors/invalid_cast.gd | 22 +++ .../scripts/runtime/errors/invalid_cast.out | 8 + .../errors/invalid_property_assignment.gd | 9 +- .../scripts/runtime/errors/modulo_by_zero.gd | 44 +++++- .../scripts/runtime/errors/modulo_by_zero.out | 9 +- .../non_static_method_call_on_native_class.gd | 7 +- ...non_static_method_call_on_native_class.out | 4 +- .../runtime/errors/read_only_dictionary.gd | 4 - .../runtime/errors/read_only_dictionary.out | 4 - .../scripts/runtime/errors/typed_array.gd | 37 +++++ .../scripts/runtime/errors/typed_array.out | 10 ++ .../typed_array_assign_basic_to_typed.gd | 4 - .../typed_array_assign_basic_to_typed.out | 2 - .../typed_array_assign_differently_typed.gd | 4 - .../typed_array_assign_differently_typed.out | 2 - .../typed_array_assign_wrong_to_typed.gd | 7 - .../typed_array_assign_wrong_to_typed.out | 5 - .../errors/typed_array_pass_basic_to_typed.gd | 7 - .../typed_array_pass_basic_to_typed.out | 2 - .../typed_array_pass_differently_to_typed.gd | 7 - .../typed_array_pass_differently_to_typed.out | 3 - .../runtime/errors/typed_dictionary.gd | 55 +++++++ .../runtime/errors/typed_dictionary.out | 18 +++ .../typed_dictionary_assign_basic_to_typed.gd | 4 - ...typed_dictionary_assign_basic_to_typed.out | 2 - ...ped_dictionary_assign_differently_typed.gd | 4 - ...ed_dictionary_assign_differently_typed.out | 2 - ...dictionary_assign_differently_typed_key.gd | 7 - ...ictionary_assign_differently_typed_key.out | 5 - ...ctionary_assign_differently_typed_value.gd | 7 - ...tionary_assign_differently_typed_value.out | 5 - .../typed_dictionary_assign_wrong_to_typed.gd | 7 - ...typed_dictionary_assign_wrong_to_typed.out | 5 - .../typed_dictionary_pass_basic_to_typed.gd | 7 - .../typed_dictionary_pass_basic_to_typed.out | 2 - ...ed_dictionary_pass_differently_to_typed.gd | 7 - ...d_dictionary_pass_differently_to_typed.out | 3 - .../errors/use_return_value_of_free_call.gd | 4 - .../errors/use_return_value_of_free_call.out | 3 - ...eturn_value_of_void_builtin_method_call.gd | 4 - ...turn_value_of_void_builtin_method_call.out | 3 - ...return_value_of_void_native_method_call.gd | 4 - ...eturn_value_of_void_native_method_call.out | 3 - .../errors/use_value_of_void_function.gd | 16 ++ .../errors/use_value_of_void_function.out | 7 + .../errors/utility_function_wrong_arg.gd | 3 - .../errors/utility_function_wrong_arg.out | 2 - .../runtime/errors/utility_functions.gd | 11 ++ .../runtime/errors/utility_functions.out | 3 + .../runtime/features/argument_count.gd | 146 +++++++++--------- .../runtime/features/const_class_reference.gd | 6 +- .../const_class_reference_external.notest.gd | 2 +- .../runtime/features/ctor_as_callable.gd | 10 +- ..._group_no_name_conflict_with_properties.gd | 2 +- .../features/single_underscore_node_name.gd | 20 +-- .../gdscript/tests/scripts/utils.notest.gd | 88 ++++++----- 428 files changed, 1309 insertions(+), 1542 deletions(-) delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/abstract_class_instantiate.out create mode 100644 modules/gdscript/tests/scripts/analyzer/errors/assign_constant.gd create mode 100644 modules/gdscript/tests/scripts/analyzer/errors/assign_constant.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/assign_enum.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/assign_enum.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/assign_named_enum.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/assign_named_enum.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/assign_signal.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/assign_signal.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/assign_to_read_only_property_indirectly.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/assign_to_read_only_property_indirectly.out rename modules/gdscript/tests/scripts/analyzer/errors/{assymetric_assignment_bad.gd => asymmetric_assignment_bad.gd} (100%) rename modules/gdscript/tests/scripts/analyzer/errors/{assymetric_assignment_bad.out => asymmetric_assignment_bad.out} (100%) rename modules/gdscript/tests/scripts/analyzer/errors/{bitwise_float_left_operand.gd => bitwise_float.gd} (63%) rename modules/gdscript/tests/scripts/analyzer/errors/{bitwise_float_right_operand.out => bitwise_float.out} (56%) delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/bitwise_float_left_operand.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/bitwise_float_right_operand.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/cast_int_to_array.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/cast_int_to_array.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/cast_int_to_object.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/cast_int_to_object.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/cast_object_to_int.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/class_name_shadows_builtin_type.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/class_name_shadows_builtin_type.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/constant_array_index_assign.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/constant_array_index_assign.out create mode 100644 modules/gdscript/tests/scripts/analyzer/errors/constant_collections.gd rename modules/gdscript/tests/scripts/analyzer/errors/{function_used_as_property.out => constant_collections.out} (57%) delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/constant_dictionary_index_assign.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/constant_dictionary_index_assign.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/constant_name_shadows_builtin_type.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/constant_name_shadows_builtin_type.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/constant_used_as_function.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/constant_used_as_function.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/cyclic_inheritance.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/cyclic_inheritance.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/cyclic_ref_const.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/cyclic_ref_const.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/cyclic_ref_enum.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/cyclic_ref_enum.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/cyclic_ref_enum_value.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/cyclic_ref_enum_value.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/cyclic_ref_external.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/cyclic_ref_external.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/cyclic_ref_external_a.notest.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/cyclic_ref_func.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/cyclic_ref_func.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/cyclic_ref_override.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/cyclic_ref_override.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/cyclic_ref_var.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/cyclic_ref_var.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/cyclic_ref_var_self.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/cyclic_ref_var_self.out create mode 100644 modules/gdscript/tests/scripts/analyzer/errors/cyclic_reference.gd create mode 100644 modules/gdscript/tests/scripts/analyzer/errors/cyclic_reference.notest.gd create mode 100644 modules/gdscript/tests/scripts/analyzer/errors/cyclic_reference.out create mode 100644 modules/gdscript/tests/scripts/analyzer/errors/dictionary_duplicate_key.gd create mode 100644 modules/gdscript/tests/scripts/analyzer/errors/dictionary_duplicate_key.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/dictionary_duplicate_key_lua.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/dictionary_duplicate_key_lua.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/dictionary_duplicate_key_lua_with_string.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/dictionary_duplicate_key_lua_with_string.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/dictionary_duplicate_key_python.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/dictionary_duplicate_key_python.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/engine_singleton_instantiate.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/engine_singleton_instantiate.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/enum_bad_method.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/enum_bad_method.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/enum_bad_value.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/enum_bad_value.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/enum_builtin_access.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/enum_builtin_access.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/enum_class_var_assign_with_wrong_enum_type.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/enum_class_var_assign_with_wrong_enum_type.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/enum_class_var_init_with_wrong_enum_type.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/enum_class_var_init_with_wrong_enum_type.out create mode 100644 modules/gdscript/tests/scripts/analyzer/errors/enum_declaration_and_usage.gd create mode 100644 modules/gdscript/tests/scripts/analyzer/errors/enum_declaration_and_usage.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/enum_duplicate_bad_method.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/enum_duplicate_bad_method.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/enum_float_value.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/enum_float_value.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/enum_function_parameter_wrong_type.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/enum_function_parameter_wrong_type.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/enum_function_return_wrong_type.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/enum_function_return_wrong_type.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/enum_global_access.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/enum_global_access.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/enum_local_var_assign_outer_with_wrong_enum_type.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/enum_local_var_assign_outer_with_wrong_enum_type.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/enum_local_var_assign_with_wrong_enum_type.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/enum_local_var_assign_with_wrong_enum_type.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/enum_local_var_init_with_wrong_enum_type.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/enum_local_var_init_with_wrong_enum_type.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/enum_name_shadows_builtin_type.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/enum_name_shadows_builtin_type.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/enum_native_access.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/enum_native_access.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/enum_native_bad_value.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/enum_native_bad_value.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/enum_preload_unnamed_assign_to_named.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/enum_preload_unnamed_assign_to_named.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/enum_shadows_base_enum.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/enum_shadows_base_enum.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/enum_string_value.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/enum_string_value.out create mode 100644 modules/gdscript/tests/scripts/analyzer/errors/enum_type_checking.gd create mode 100644 modules/gdscript/tests/scripts/analyzer/errors/enum_type_checking.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/enum_unnamed_assign_to_named.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/enum_unnamed_assign_to_named.out create mode 100644 modules/gdscript/tests/scripts/analyzer/errors/export_node_in_non_node_derived_class.gd create mode 100644 modules/gdscript/tests/scripts/analyzer/errors/export_node_in_non_node_derived_class.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/export_node_in_non_node_derived_class_1.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/export_node_in_non_node_derived_class_1.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/export_node_in_non_node_derived_class_2.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/export_node_in_non_node_derived_class_2.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/export_node_in_non_node_derived_class_3.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/export_node_in_non_node_derived_class_3.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/extend_engine_singleton.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/extend_engine_singleton.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/extend_non_class_constant_1.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/extend_non_class_constant_1.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/extend_non_class_constant_2.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/extend_non_class_constant_2.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/extend_non_gdscript_nested.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/extend_non_gdscript_nested.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/extend_unknown.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/extend_unknown.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/extend_variable.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/extend_variable.out create mode 100644 modules/gdscript/tests/scripts/analyzer/errors/for_loop_inferred_type.gd create mode 100644 modules/gdscript/tests/scripts/analyzer/errors/for_loop_inferred_type.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/for_loop_on_constant_float.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/for_loop_on_constant_float.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/for_loop_on_constant_int.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/for_loop_on_constant_int.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/for_loop_on_enum_value.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/for_loop_on_enum_value.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/for_loop_on_hard_float.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/for_loop_on_hard_float.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/for_loop_on_hard_int.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/for_loop_on_hard_int.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/for_loop_on_hard_iterator.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/for_loop_on_hard_iterator.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/for_loop_on_hard_string.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/for_loop_on_hard_string.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/for_loop_on_literal_bool.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/for_loop_on_literal_bool.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/for_loop_on_literal_int.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/for_loop_on_literal_int.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/for_loop_wrong_specified_type_with_literal_array.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/for_loop_wrong_specified_type_with_literal_array.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/for_loop_wrong_specified_type_with_literal_dictionary.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/for_loop_wrong_specified_type_with_literal_dictionary.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/function_dont_match_parent_signature_parameter_count_less.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/function_dont_match_parent_signature_parameter_count_less.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/function_dont_match_parent_signature_parameter_count_more.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/function_dont_match_parent_signature_parameter_count_more.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/function_dont_match_parent_signature_parameter_default_values.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/function_dont_match_parent_signature_parameter_default_values.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/function_dont_match_parent_signature_parameter_type.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/function_dont_match_parent_signature_parameter_type.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/function_dont_match_parent_signature_return_type.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/function_dont_match_parent_signature_return_type.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/function_param_type_invalid_contravariance_1.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/function_param_type_invalid_contravariance_1.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/function_param_type_invalid_contravariance_2.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/function_param_type_invalid_contravariance_2.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/function_param_type_invalid_contravariance_3.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/function_param_type_invalid_contravariance_3.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/function_return_type_invalid_covariance_1.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/function_return_type_invalid_covariance_1.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/function_return_type_invalid_covariance_2.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/function_return_type_invalid_covariance_2.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/function_return_type_invalid_covariance_3.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/function_return_type_invalid_covariance_3.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/function_return_type_invalid_covariance_4.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/function_return_type_invalid_covariance_4.out create mode 100644 modules/gdscript/tests/scripts/analyzer/errors/function_signature_compatibility.gd create mode 100644 modules/gdscript/tests/scripts/analyzer/errors/function_signature_compatibility.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/function_used_as_property.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/gd_utility_function_wrong_arg.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/gd_utility_function_wrong_arg.out create mode 100644 modules/gdscript/tests/scripts/analyzer/errors/get_node_shorthand.gd rename modules/gdscript/tests/scripts/analyzer/errors/{get_node_shorthand_within_non_node.out => get_node_shorthand.out} (53%) delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/get_node_shorthand_in_static_function.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/get_node_shorthand_in_static_function.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/get_node_shorthand_within_non_node.gd create mode 100644 modules/gdscript/tests/scripts/analyzer/errors/inferring_with_weak_type.gd create mode 100644 modules/gdscript/tests/scripts/analyzer/errors/inferring_with_weak_type.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/inferring_with_weak_type_local_variable.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/inferring_with_weak_type_local_variable.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/inferring_with_weak_type_member_variable.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/inferring_with_weak_type_member_variable.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/inferring_with_weak_type_parameter.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/inferring_with_weak_type_parameter.out rename modules/gdscript/tests/scripts/analyzer/errors/{cast_object_to_int.gd => invalid_cast.gd} (50%) create mode 100644 modules/gdscript/tests/scripts/analyzer/errors/invalid_cast.out rename modules/gdscript/tests/scripts/analyzer/errors/{invalid_concatenation_dictionary.gd => invalid_concatenation.gd} (56%) create mode 100644 modules/gdscript/tests/scripts/analyzer/errors/invalid_concatenation.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/invalid_concatenation_bool.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/invalid_concatenation_bool.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/invalid_concatenation_dictionary.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/invalid_concatenation_mixed.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/invalid_concatenation_mixed.out create mode 100644 modules/gdscript/tests/scripts/analyzer/errors/invalid_inheritance.gd create mode 100644 modules/gdscript/tests/scripts/analyzer/errors/invalid_inheritance.out rename modules/gdscript/tests/scripts/analyzer/errors/{abstract_class_instantiate.gd => invalid_instantiation.gd} (87%) create mode 100644 modules/gdscript/tests/scripts/analyzer/errors/invalid_instantiation.out create mode 100644 modules/gdscript/tests/scripts/analyzer/errors/invalid_member_usage.gd create mode 100644 modules/gdscript/tests/scripts/analyzer/errors/invalid_member_usage.out create mode 100644 modules/gdscript/tests/scripts/analyzer/errors/invalid_return.gd create mode 100644 modules/gdscript/tests/scripts/analyzer/errors/invalid_return.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/lambda_cyclic_ref_call_arg.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/lambda_cyclic_ref_call_arg.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/lambda_cyclic_ref_param.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/lambda_cyclic_ref_param.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/lambda_no_return.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/lambda_no_return.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/lambda_wrong_return.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/lambda_wrong_return.out create mode 100644 modules/gdscript/tests/scripts/analyzer/errors/local_const_as_type.gd create mode 100644 modules/gdscript/tests/scripts/analyzer/errors/local_const_as_type.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/local_const_as_type_use_before_declared.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/local_const_as_type_use_before_declared.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/local_const_as_type_use_not_const.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/local_const_as_type_use_not_const.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/local_const_as_type_use_not_type.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/local_const_as_type_use_not_type.out create mode 100644 modules/gdscript/tests/scripts/analyzer/errors/match.gd create mode 100644 modules/gdscript/tests/scripts/analyzer/errors/match.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/match_guard_invalid_expression.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/match_guard_invalid_expression.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/match_with_subscript.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/match_with_subscript.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/match_with_variable_expression.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/match_with_variable_expression.out rename modules/gdscript/tests/scripts/analyzer/errors/{native_type_errors.gd => not_found_member.gd} (100%) rename modules/gdscript/tests/scripts/analyzer/errors/{native_type_errors.out => not_found_member.out} (100%) delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/preload_enum_error.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/preload_enum_error.out create mode 100644 modules/gdscript/tests/scripts/analyzer/errors/properties.gd create mode 100644 modules/gdscript/tests/scripts/analyzer/errors/properties.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/property_function_get_type_error.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/property_function_get_type_error.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/property_function_set_type_error.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/property_function_set_type_error.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/property_inline_get_type_error.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/property_inline_get_type_error.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/property_inline_set_type_error.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/property_inline_set_type_error.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/property_used_as_function.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/property_used_as_function.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/redefine_class_constant.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/redefine_class_constant.out create mode 100644 modules/gdscript/tests/scripts/analyzer/errors/redefine_constant.gd create mode 100644 modules/gdscript/tests/scripts/analyzer/errors/redefine_constant.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/redefine_local_constant.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/redefine_local_constant.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/return_null_in_void_func.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/return_null_in_void_func.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/return_variant_in_void_func.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/return_variant_in_void_func.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/setter_parameter_uses_property_type.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/setter_parameter_uses_property_type.out create mode 100644 modules/gdscript/tests/scripts/analyzer/errors/shadowing.gd create mode 100644 modules/gdscript/tests/scripts/analyzer/errors/shadowing.out create mode 100644 modules/gdscript/tests/scripts/analyzer/errors/static_access_non_static.gd create mode 100644 modules/gdscript/tests/scripts/analyzer/errors/static_access_non_static.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/static_constructor_with_return_type.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/static_constructor_with_return_type.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/static_func_access_non_static.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/static_func_access_non_static.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/static_func_access_non_static_in_lambda_param.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/static_func_access_non_static_in_lambda_param.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/static_func_call_non_static.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/static_func_call_non_static.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/static_func_call_non_static_in_lambda.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/static_func_call_non_static_in_lambda.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/static_func_call_non_static_in_lambda_param.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/static_func_call_non_static_in_lambda_param.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/static_var_init_access_non_static_in_lambda.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/static_var_init_access_non_static_in_lambda.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/static_var_init_access_non_static_in_lambda_setter.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/static_var_init_access_non_static_in_lambda_setter.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/static_var_init_call_non_static_in_lambda.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/static_var_init_call_non_static_in_lambda.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/static_var_init_call_non_static_in_lambda_setter.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/static_var_init_call_non_static_in_lambda_setter.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/static_var_init_non_static_access.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/static_var_init_non_static_access.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/static_var_init_non_static_call.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/static_var_init_non_static_call.out create mode 100644 modules/gdscript/tests/scripts/analyzer/errors/typed_array.gd create mode 100644 modules/gdscript/tests/scripts/analyzer/errors/typed_array.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/typed_array_assign_differently_typed.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/typed_array_assign_differently_typed.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/typed_array_assignment.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/typed_array_assignment.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/typed_array_init_with_unconvertable_in_literal.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/typed_array_init_with_unconvertable_in_literal.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/typed_array_pass_differently_to_typed.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/typed_array_pass_differently_to_typed.out create mode 100644 modules/gdscript/tests/scripts/analyzer/errors/typed_dictionary.gd create mode 100644 modules/gdscript/tests/scripts/analyzer/errors/typed_dictionary.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/typed_dictionary_assign_differently_typed.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/typed_dictionary_assign_differently_typed.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/typed_dictionary_assignment.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/typed_dictionary_assignment.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/typed_dictionary_init_with_unconvertible_in_literal.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/typed_dictionary_init_with_unconvertible_in_literal.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/typed_dictionary_pass_differently_to_typed.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/typed_dictionary_pass_differently_to_typed.out create mode 100644 modules/gdscript/tests/scripts/analyzer/errors/use_value_of_void_function.gd create mode 100644 modules/gdscript/tests/scripts/analyzer/errors/use_value_of_void_function.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/use_value_of_void_function_builtin_method.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/use_value_of_void_function_builtin_method.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/use_value_of_void_function_custom_method.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/use_value_of_void_function_custom_method.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/use_value_of_void_function_gd_utility.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/use_value_of_void_function_gd_utility.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/use_value_of_void_function_native_method.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/use_value_of_void_function_native_method.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/use_value_of_void_function_utility.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/use_value_of_void_function_utility.out rename modules/gdscript/tests/scripts/analyzer/errors/{utility_function_wrong_arg.gd => utility_functions.gd} (56%) rename modules/gdscript/tests/scripts/analyzer/errors/{utility_function_wrong_arg.out => utility_functions.out} (64%) delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/variable_name_shadows_builtin_type.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/errors/variable_name_shadows_builtin_type.out rename modules/gdscript/tests/scripts/analyzer/warnings/{shadowning.gd => shadowing.gd} (100%) rename modules/gdscript/tests/scripts/analyzer/warnings/{shadowning.out => shadowing.out} (98%) create mode 100644 modules/gdscript/tests/scripts/parser/features/multiline_preload.gd create mode 100644 modules/gdscript/tests/scripts/parser/features/multiline_preload.out delete mode 100644 modules/gdscript/tests/scripts/runtime/errors/cast_freed_object.gd delete mode 100644 modules/gdscript/tests/scripts/runtime/errors/cast_freed_object.out delete mode 100644 modules/gdscript/tests/scripts/runtime/errors/cast_int_to_array.gd delete mode 100644 modules/gdscript/tests/scripts/runtime/errors/cast_int_to_array.out delete mode 100644 modules/gdscript/tests/scripts/runtime/errors/cast_int_to_object.gd delete mode 100644 modules/gdscript/tests/scripts/runtime/errors/cast_int_to_object.out delete mode 100644 modules/gdscript/tests/scripts/runtime/errors/cast_object_to_int.gd delete mode 100644 modules/gdscript/tests/scripts/runtime/errors/cast_object_to_int.out delete mode 100644 modules/gdscript/tests/scripts/runtime/errors/constant_array_is_deep.gd delete mode 100644 modules/gdscript/tests/scripts/runtime/errors/constant_array_is_deep.out create mode 100644 modules/gdscript/tests/scripts/runtime/errors/constant_collections.gd create mode 100644 modules/gdscript/tests/scripts/runtime/errors/constant_collections.out delete mode 100644 modules/gdscript/tests/scripts/runtime/errors/constant_dictionary_is_deep.gd delete mode 100644 modules/gdscript/tests/scripts/runtime/errors/constant_dictionary_is_deep.out delete mode 100644 modules/gdscript/tests/scripts/runtime/errors/gd_utility_function_wrong_arg.gd delete mode 100644 modules/gdscript/tests/scripts/runtime/errors/gd_utility_function_wrong_arg.out create mode 100644 modules/gdscript/tests/scripts/runtime/errors/invalid_cast.gd create mode 100644 modules/gdscript/tests/scripts/runtime/errors/invalid_cast.out delete mode 100644 modules/gdscript/tests/scripts/runtime/errors/read_only_dictionary.gd delete mode 100644 modules/gdscript/tests/scripts/runtime/errors/read_only_dictionary.out create mode 100644 modules/gdscript/tests/scripts/runtime/errors/typed_array.gd create mode 100644 modules/gdscript/tests/scripts/runtime/errors/typed_array.out delete mode 100644 modules/gdscript/tests/scripts/runtime/errors/typed_array_assign_basic_to_typed.gd delete mode 100644 modules/gdscript/tests/scripts/runtime/errors/typed_array_assign_basic_to_typed.out delete mode 100644 modules/gdscript/tests/scripts/runtime/errors/typed_array_assign_differently_typed.gd delete mode 100644 modules/gdscript/tests/scripts/runtime/errors/typed_array_assign_differently_typed.out delete mode 100644 modules/gdscript/tests/scripts/runtime/errors/typed_array_assign_wrong_to_typed.gd delete mode 100644 modules/gdscript/tests/scripts/runtime/errors/typed_array_assign_wrong_to_typed.out delete mode 100644 modules/gdscript/tests/scripts/runtime/errors/typed_array_pass_basic_to_typed.gd delete mode 100644 modules/gdscript/tests/scripts/runtime/errors/typed_array_pass_basic_to_typed.out delete mode 100644 modules/gdscript/tests/scripts/runtime/errors/typed_array_pass_differently_to_typed.gd delete mode 100644 modules/gdscript/tests/scripts/runtime/errors/typed_array_pass_differently_to_typed.out create mode 100644 modules/gdscript/tests/scripts/runtime/errors/typed_dictionary.gd create mode 100644 modules/gdscript/tests/scripts/runtime/errors/typed_dictionary.out delete mode 100644 modules/gdscript/tests/scripts/runtime/errors/typed_dictionary_assign_basic_to_typed.gd delete mode 100644 modules/gdscript/tests/scripts/runtime/errors/typed_dictionary_assign_basic_to_typed.out delete mode 100644 modules/gdscript/tests/scripts/runtime/errors/typed_dictionary_assign_differently_typed.gd delete mode 100644 modules/gdscript/tests/scripts/runtime/errors/typed_dictionary_assign_differently_typed.out delete mode 100644 modules/gdscript/tests/scripts/runtime/errors/typed_dictionary_assign_differently_typed_key.gd delete mode 100644 modules/gdscript/tests/scripts/runtime/errors/typed_dictionary_assign_differently_typed_key.out delete mode 100644 modules/gdscript/tests/scripts/runtime/errors/typed_dictionary_assign_differently_typed_value.gd delete mode 100644 modules/gdscript/tests/scripts/runtime/errors/typed_dictionary_assign_differently_typed_value.out delete mode 100644 modules/gdscript/tests/scripts/runtime/errors/typed_dictionary_assign_wrong_to_typed.gd delete mode 100644 modules/gdscript/tests/scripts/runtime/errors/typed_dictionary_assign_wrong_to_typed.out delete mode 100644 modules/gdscript/tests/scripts/runtime/errors/typed_dictionary_pass_basic_to_typed.gd delete mode 100644 modules/gdscript/tests/scripts/runtime/errors/typed_dictionary_pass_basic_to_typed.out delete mode 100644 modules/gdscript/tests/scripts/runtime/errors/typed_dictionary_pass_differently_to_typed.gd delete mode 100644 modules/gdscript/tests/scripts/runtime/errors/typed_dictionary_pass_differently_to_typed.out delete mode 100644 modules/gdscript/tests/scripts/runtime/errors/use_return_value_of_free_call.gd delete mode 100644 modules/gdscript/tests/scripts/runtime/errors/use_return_value_of_free_call.out delete mode 100644 modules/gdscript/tests/scripts/runtime/errors/use_return_value_of_void_builtin_method_call.gd delete mode 100644 modules/gdscript/tests/scripts/runtime/errors/use_return_value_of_void_builtin_method_call.out delete mode 100644 modules/gdscript/tests/scripts/runtime/errors/use_return_value_of_void_native_method_call.gd delete mode 100644 modules/gdscript/tests/scripts/runtime/errors/use_return_value_of_void_native_method_call.out create mode 100644 modules/gdscript/tests/scripts/runtime/errors/use_value_of_void_function.gd create mode 100644 modules/gdscript/tests/scripts/runtime/errors/use_value_of_void_function.out delete mode 100644 modules/gdscript/tests/scripts/runtime/errors/utility_function_wrong_arg.gd delete mode 100644 modules/gdscript/tests/scripts/runtime/errors/utility_function_wrong_arg.out create mode 100644 modules/gdscript/tests/scripts/runtime/errors/utility_functions.gd create mode 100644 modules/gdscript/tests/scripts/runtime/errors/utility_functions.out diff --git a/modules/gdscript/gdscript_analyzer.cpp b/modules/gdscript/gdscript_analyzer.cpp index 801776763cc..07dbb2ac26e 100644 --- a/modules/gdscript/gdscript_analyzer.cpp +++ b/modules/gdscript/gdscript_analyzer.cpp @@ -640,15 +640,15 @@ Error GDScriptAnalyzer::resolve_class_inheritance(GDScriptParser::ClassNode *p_c if (p_recursive) { for (int i = 0; i < p_class->members.size(); i++) { if (p_class->members[i].type == GDScriptParser::ClassNode::Member::CLASS) { - err = resolve_class_inheritance(p_class->members[i].m_class, true); - if (err) { - return err; + const Error inner_err = resolve_class_inheritance(p_class->members[i].m_class, true); + if (inner_err != OK && err == OK) { + err = inner_err; } } } } - return OK; + return err; } GDScriptParser::DataType GDScriptAnalyzer::resolve_datatype(GDScriptParser::TypeNode *p_type) { diff --git a/modules/gdscript/tests/gdscript_test_runner.cpp b/modules/gdscript/tests/gdscript_test_runner.cpp index 4728976b9af..84a0886bbc1 100644 --- a/modules/gdscript/tests/gdscript_test_runner.cpp +++ b/modules/gdscript/tests/gdscript_test_runner.cpp @@ -575,8 +575,20 @@ GDScriptTest::TestResult GDScriptTest::execute_test_code(bool p_is_generating) { result.status = GDTEST_ANALYZER_ERROR; result.output = get_text_for_status(result.status) + "\n"; + // Errors are stored in the order they were added, which may not match the source code. + // Here we sort only by lines, preserving the original order for columns. + // So, within a single line, the primary error is printed first, not cascading ones. + struct SortErrors { + _FORCE_INLINE_ bool operator()(const GDScriptParser::ParserError &p_a, const GDScriptParser::ParserError &p_b) const { + return p_a.start_line < p_b.start_line; + } + }; + + List errors = List(parser.get_errors()); + errors.sort_custom(); + StringBuilder error_string; - for (const GDScriptParser::ParserError &error : parser.get_errors()) { + for (const GDScriptParser::ParserError &error : errors) { error_string.append(vformat(">> ERROR at line %d: %s\n", error.start_line, error.message)); } result.output += error_string.as_string(); diff --git a/modules/gdscript/tests/scripts/analyzer/errors/abstract_class_instantiate.out b/modules/gdscript/tests/scripts/analyzer/errors/abstract_class_instantiate.out deleted file mode 100644 index 29200fd76c4..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/abstract_class_instantiate.out +++ /dev/null @@ -1,5 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 9: Native class "InstancePlaceholder" cannot be constructed as it is abstract. ->> ERROR at line 9: Name "new" is a Callable. You can call it with "new.call()" instead. ->> ERROR at line 10: Class "abstract_class_instantiate.gd::B" cannot be constructed as it is based on abstract native class "InstancePlaceholder". ->> ERROR at line 10: Name "new" is a Callable. You can call it with "new.call()" instead. diff --git a/modules/gdscript/tests/scripts/analyzer/errors/abstract_methods.out b/modules/gdscript/tests/scripts/analyzer/errors/abstract_methods.out index e6375704383..d70dc694293 100644 --- a/modules/gdscript/tests/scripts/analyzer/errors/abstract_methods.out +++ b/modules/gdscript/tests/scripts/analyzer/errors/abstract_methods.out @@ -1,13 +1,13 @@ GDTEST_ANALYZER_ERROR ->> ERROR at line 37: "@abstract" annotation can only be used once per class. ->> ERROR at line 28: "@abstract" annotation can only be used once per function. ->> ERROR at line 35: "@abstract" annotation cannot be applied to static functions. ->> ERROR at line 40: A lambda function must have a ":" followed by a body. ->> ERROR at line 41: A lambda function must have a ":" followed by a body. >> ERROR at line 11: Class "Test1" is not abstract but contains abstract methods. Mark the class as "@abstract" or remove "@abstract" from all methods in this class. >> ERROR at line 14: Class "Test2" must implement "AbstractClass.some_func()" and other inherited abstract methods or be marked as "@abstract". >> ERROR at line 17: Class "Test3" must implement "AbstractClassAgain.some_func()" and other inherited abstract methods or be marked as "@abstract". >> ERROR at line 22: Cannot call the parent class' abstract function "some_func()" because it hasn't been defined. >> ERROR at line 25: Cannot call the parent class' abstract function "some_func()" because it hasn't been defined. +>> ERROR at line 28: "@abstract" annotation can only be used once per function. >> ERROR at line 32: An abstract function cannot have a body. +>> ERROR at line 35: "@abstract" annotation cannot be applied to static functions. >> ERROR at line 35: A function must either have a ":" followed by a body, or be marked as "@abstract". +>> ERROR at line 37: "@abstract" annotation can only be used once per class. +>> ERROR at line 40: A lambda function must have a ":" followed by a body. +>> ERROR at line 41: A lambda function must have a ":" followed by a body. diff --git a/modules/gdscript/tests/scripts/analyzer/errors/assign_constant.gd b/modules/gdscript/tests/scripts/analyzer/errors/assign_constant.gd new file mode 100644 index 00000000000..43143221709 --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/errors/assign_constant.gd @@ -0,0 +1,14 @@ +enum { VALUE } +enum NamedEnum { VALUE } + +const CONST = 0 + +signal signal_1 +signal signal_2 + +func test(): + VALUE = 1 + NamedEnum = {} + NamedEnum.VALUE = 1 + CONST = 1 + signal_1 = signal_2 diff --git a/modules/gdscript/tests/scripts/analyzer/errors/assign_constant.out b/modules/gdscript/tests/scripts/analyzer/errors/assign_constant.out new file mode 100644 index 00000000000..8c25080e168 --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/errors/assign_constant.out @@ -0,0 +1,6 @@ +GDTEST_ANALYZER_ERROR +>> ERROR at line 10: Cannot assign a new value to a constant. +>> ERROR at line 11: Cannot assign a new value to a constant. +>> ERROR at line 12: Cannot assign a new value to a constant. +>> ERROR at line 13: Cannot assign a new value to a constant. +>> ERROR at line 14: Cannot assign a new value to a constant. diff --git a/modules/gdscript/tests/scripts/analyzer/errors/assign_enum.gd b/modules/gdscript/tests/scripts/analyzer/errors/assign_enum.gd deleted file mode 100644 index 8123fc53d92..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/assign_enum.gd +++ /dev/null @@ -1,3 +0,0 @@ -enum { V } -func test(): - V = 1 diff --git a/modules/gdscript/tests/scripts/analyzer/errors/assign_enum.out b/modules/gdscript/tests/scripts/analyzer/errors/assign_enum.out deleted file mode 100644 index bbebbe62395..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/assign_enum.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 3: Cannot assign a new value to a constant. diff --git a/modules/gdscript/tests/scripts/analyzer/errors/assign_named_enum.gd b/modules/gdscript/tests/scripts/analyzer/errors/assign_named_enum.gd deleted file mode 100644 index da2b13d6900..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/assign_named_enum.gd +++ /dev/null @@ -1,3 +0,0 @@ -enum NamedEnum { V } -func test(): - NamedEnum.V = 1 diff --git a/modules/gdscript/tests/scripts/analyzer/errors/assign_named_enum.out b/modules/gdscript/tests/scripts/analyzer/errors/assign_named_enum.out deleted file mode 100644 index bbebbe62395..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/assign_named_enum.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 3: Cannot assign a new value to a constant. diff --git a/modules/gdscript/tests/scripts/analyzer/errors/assign_signal.gd b/modules/gdscript/tests/scripts/analyzer/errors/assign_signal.gd deleted file mode 100644 index 0e1f7256f8c..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/assign_signal.gd +++ /dev/null @@ -1,4 +0,0 @@ -signal your_base -signal my_base -func test(): - your_base = my_base diff --git a/modules/gdscript/tests/scripts/analyzer/errors/assign_signal.out b/modules/gdscript/tests/scripts/analyzer/errors/assign_signal.out deleted file mode 100644 index 876cad671e9..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/assign_signal.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 4: Cannot assign a new value to a constant. diff --git a/modules/gdscript/tests/scripts/analyzer/errors/assign_to_read_only_property.gd b/modules/gdscript/tests/scripts/analyzer/errors/assign_to_read_only_property.gd index 2b1c4c95949..045fea0ed0a 100644 --- a/modules/gdscript/tests/scripts/analyzer/errors/assign_to_read_only_property.gd +++ b/modules/gdscript/tests/scripts/analyzer/errors/assign_to_read_only_property.gd @@ -1,4 +1,10 @@ func test(): + # Directly. var tree := SceneTree.new() tree.root = Window.new() tree.free() + + # Indirectly. + var state := PhysicsDirectBodyState3DExtension.new() + state.center_of_mass.x += 1.0 + state.free() diff --git a/modules/gdscript/tests/scripts/analyzer/errors/assign_to_read_only_property.out b/modules/gdscript/tests/scripts/analyzer/errors/assign_to_read_only_property.out index 1d3858f251b..146e1268184 100644 --- a/modules/gdscript/tests/scripts/analyzer/errors/assign_to_read_only_property.out +++ b/modules/gdscript/tests/scripts/analyzer/errors/assign_to_read_only_property.out @@ -1,2 +1,3 @@ GDTEST_ANALYZER_ERROR ->> ERROR at line 3: Cannot assign a new value to a read-only property. +>> ERROR at line 4: Cannot assign a new value to a read-only property. +>> ERROR at line 9: Cannot assign a new value to a read-only property. diff --git a/modules/gdscript/tests/scripts/analyzer/errors/assign_to_read_only_property_indirectly.gd b/modules/gdscript/tests/scripts/analyzer/errors/assign_to_read_only_property_indirectly.gd deleted file mode 100644 index c97ee0ea690..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/assign_to_read_only_property_indirectly.gd +++ /dev/null @@ -1,4 +0,0 @@ -func test(): - var state := PhysicsDirectBodyState3DExtension.new() - state.center_of_mass.x += 1.0 - state.free() diff --git a/modules/gdscript/tests/scripts/analyzer/errors/assign_to_read_only_property_indirectly.out b/modules/gdscript/tests/scripts/analyzer/errors/assign_to_read_only_property_indirectly.out deleted file mode 100644 index 1d3858f251b..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/assign_to_read_only_property_indirectly.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 3: Cannot assign a new value to a read-only property. diff --git a/modules/gdscript/tests/scripts/analyzer/errors/assymetric_assignment_bad.gd b/modules/gdscript/tests/scripts/analyzer/errors/asymmetric_assignment_bad.gd similarity index 100% rename from modules/gdscript/tests/scripts/analyzer/errors/assymetric_assignment_bad.gd rename to modules/gdscript/tests/scripts/analyzer/errors/asymmetric_assignment_bad.gd diff --git a/modules/gdscript/tests/scripts/analyzer/errors/assymetric_assignment_bad.out b/modules/gdscript/tests/scripts/analyzer/errors/asymmetric_assignment_bad.out similarity index 100% rename from modules/gdscript/tests/scripts/analyzer/errors/assymetric_assignment_bad.out rename to modules/gdscript/tests/scripts/analyzer/errors/asymmetric_assignment_bad.out diff --git a/modules/gdscript/tests/scripts/analyzer/errors/bitwise_float_left_operand.gd b/modules/gdscript/tests/scripts/analyzer/errors/bitwise_float.gd similarity index 63% rename from modules/gdscript/tests/scripts/analyzer/errors/bitwise_float_left_operand.gd rename to modules/gdscript/tests/scripts/analyzer/errors/bitwise_float.gd index 9b722ea50a7..94d8888e5f2 100644 --- a/modules/gdscript/tests/scripts/analyzer/errors/bitwise_float_left_operand.gd +++ b/modules/gdscript/tests/scripts/analyzer/errors/bitwise_float.gd @@ -1,3 +1,3 @@ func test(): - # Error here. print(2.2 << 4) + print(2 >> 4.4) diff --git a/modules/gdscript/tests/scripts/analyzer/errors/bitwise_float_right_operand.out b/modules/gdscript/tests/scripts/analyzer/errors/bitwise_float.out similarity index 56% rename from modules/gdscript/tests/scripts/analyzer/errors/bitwise_float_right_operand.out rename to modules/gdscript/tests/scripts/analyzer/errors/bitwise_float.out index 70a56196f82..83394f57173 100644 --- a/modules/gdscript/tests/scripts/analyzer/errors/bitwise_float_right_operand.out +++ b/modules/gdscript/tests/scripts/analyzer/errors/bitwise_float.out @@ -1,2 +1,3 @@ GDTEST_ANALYZER_ERROR +>> ERROR at line 2: Invalid operands to operator <<, float and int. >> ERROR at line 3: Invalid operands to operator >>, int and float. diff --git a/modules/gdscript/tests/scripts/analyzer/errors/bitwise_float_left_operand.out b/modules/gdscript/tests/scripts/analyzer/errors/bitwise_float_left_operand.out deleted file mode 100644 index ec4f6568fe7..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/bitwise_float_left_operand.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 3: Invalid operands to operator <<, float and int. diff --git a/modules/gdscript/tests/scripts/analyzer/errors/bitwise_float_right_operand.gd b/modules/gdscript/tests/scripts/analyzer/errors/bitwise_float_right_operand.gd deleted file mode 100644 index 0a4f647f579..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/bitwise_float_right_operand.gd +++ /dev/null @@ -1,3 +0,0 @@ -func test(): - # Error here. - print(2 >> 4.4) diff --git a/modules/gdscript/tests/scripts/analyzer/errors/cast_int_to_array.gd b/modules/gdscript/tests/scripts/analyzer/errors/cast_int_to_array.gd deleted file mode 100644 index b53e814eea7..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/cast_int_to_array.gd +++ /dev/null @@ -1,3 +0,0 @@ -func test(): - var integer := 1 - print(integer as Array) diff --git a/modules/gdscript/tests/scripts/analyzer/errors/cast_int_to_array.out b/modules/gdscript/tests/scripts/analyzer/errors/cast_int_to_array.out deleted file mode 100644 index 203fa04e499..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/cast_int_to_array.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 3: Invalid cast. Cannot convert from "int" to "Array". diff --git a/modules/gdscript/tests/scripts/analyzer/errors/cast_int_to_object.gd b/modules/gdscript/tests/scripts/analyzer/errors/cast_int_to_object.gd deleted file mode 100644 index 323e367f8e9..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/cast_int_to_object.gd +++ /dev/null @@ -1,3 +0,0 @@ -func test(): - var integer := 1 - print(integer as Node) diff --git a/modules/gdscript/tests/scripts/analyzer/errors/cast_int_to_object.out b/modules/gdscript/tests/scripts/analyzer/errors/cast_int_to_object.out deleted file mode 100644 index 0dd12f1f0f0..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/cast_int_to_object.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 3: Invalid cast. Cannot convert from "int" to "Node". diff --git a/modules/gdscript/tests/scripts/analyzer/errors/cast_object_to_int.out b/modules/gdscript/tests/scripts/analyzer/errors/cast_object_to_int.out deleted file mode 100644 index 0cfefc20af2..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/cast_object_to_int.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 3: Invalid cast. Cannot convert from "RefCounted" to "int". diff --git a/modules/gdscript/tests/scripts/analyzer/errors/class_name_shadows_builtin_type.gd b/modules/gdscript/tests/scripts/analyzer/errors/class_name_shadows_builtin_type.gd deleted file mode 100644 index b84ccdce81b..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/class_name_shadows_builtin_type.gd +++ /dev/null @@ -1,5 +0,0 @@ -class Vector2: - pass - -func test(): - pass diff --git a/modules/gdscript/tests/scripts/analyzer/errors/class_name_shadows_builtin_type.out b/modules/gdscript/tests/scripts/analyzer/errors/class_name_shadows_builtin_type.out deleted file mode 100644 index 24e9714d857..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/class_name_shadows_builtin_type.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 1: Class "Vector2" hides a built-in type. diff --git a/modules/gdscript/tests/scripts/analyzer/errors/constant_array_index_assign.gd b/modules/gdscript/tests/scripts/analyzer/errors/constant_array_index_assign.gd deleted file mode 100644 index b8603dd4ca5..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/constant_array_index_assign.gd +++ /dev/null @@ -1,5 +0,0 @@ -const array: Array = [0] - -func test(): - var key: int = 0 - array[key] = 0 diff --git a/modules/gdscript/tests/scripts/analyzer/errors/constant_array_index_assign.out b/modules/gdscript/tests/scripts/analyzer/errors/constant_array_index_assign.out deleted file mode 100644 index 134de681110..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/constant_array_index_assign.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 5: Cannot assign a new value to a constant. diff --git a/modules/gdscript/tests/scripts/analyzer/errors/constant_collections.gd b/modules/gdscript/tests/scripts/analyzer/errors/constant_collections.gd new file mode 100644 index 00000000000..85152d53b07 --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/errors/constant_collections.gd @@ -0,0 +1,7 @@ +const ARRAY: Array = [0] +const DICTIONARY: Dictionary = { 0: 0 } + +func test(): + var key: int = 0 + ARRAY[key] = 0 + DICTIONARY[key] = 0 diff --git a/modules/gdscript/tests/scripts/analyzer/errors/function_used_as_property.out b/modules/gdscript/tests/scripts/analyzer/errors/constant_collections.out similarity index 57% rename from modules/gdscript/tests/scripts/analyzer/errors/function_used_as_property.out rename to modules/gdscript/tests/scripts/analyzer/errors/constant_collections.out index 8567a08532f..f0a5da4f2c0 100644 --- a/modules/gdscript/tests/scripts/analyzer/errors/function_used_as_property.out +++ b/modules/gdscript/tests/scripts/analyzer/errors/constant_collections.out @@ -1,2 +1,3 @@ GDTEST_ANALYZER_ERROR >> ERROR at line 6: Cannot assign a new value to a constant. +>> ERROR at line 7: Cannot assign a new value to a constant. diff --git a/modules/gdscript/tests/scripts/analyzer/errors/constant_dictionary_index_assign.gd b/modules/gdscript/tests/scripts/analyzer/errors/constant_dictionary_index_assign.gd deleted file mode 100644 index 9b5112b7881..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/constant_dictionary_index_assign.gd +++ /dev/null @@ -1,5 +0,0 @@ -const dictionary := {} - -func test(): - var key: int = 0 - dictionary[key] = 0 diff --git a/modules/gdscript/tests/scripts/analyzer/errors/constant_dictionary_index_assign.out b/modules/gdscript/tests/scripts/analyzer/errors/constant_dictionary_index_assign.out deleted file mode 100644 index 134de681110..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/constant_dictionary_index_assign.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 5: Cannot assign a new value to a constant. diff --git a/modules/gdscript/tests/scripts/analyzer/errors/constant_name_shadows_builtin_type.gd b/modules/gdscript/tests/scripts/analyzer/errors/constant_name_shadows_builtin_type.gd deleted file mode 100644 index a7c0a29a692..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/constant_name_shadows_builtin_type.gd +++ /dev/null @@ -1,4 +0,0 @@ -const Vector2 = 0 - -func test(): - pass diff --git a/modules/gdscript/tests/scripts/analyzer/errors/constant_name_shadows_builtin_type.out b/modules/gdscript/tests/scripts/analyzer/errors/constant_name_shadows_builtin_type.out deleted file mode 100644 index ce8d9807b2f..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/constant_name_shadows_builtin_type.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 1: The member "Vector2" cannot have the same name as a builtin type. diff --git a/modules/gdscript/tests/scripts/analyzer/errors/constant_used_as_function.gd b/modules/gdscript/tests/scripts/analyzer/errors/constant_used_as_function.gd deleted file mode 100644 index 0ad2337c154..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/constant_used_as_function.gd +++ /dev/null @@ -1,5 +0,0 @@ -const CONSTANT = 25 - - -func test(): - CONSTANT(123) diff --git a/modules/gdscript/tests/scripts/analyzer/errors/constant_used_as_function.out b/modules/gdscript/tests/scripts/analyzer/errors/constant_used_as_function.out deleted file mode 100644 index dc28ae46be4..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/constant_used_as_function.out +++ /dev/null @@ -1,3 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 5: Member "CONSTANT" is not a function. ->> ERROR at line 5: Name "CONSTANT" called as a function but is a "int". diff --git a/modules/gdscript/tests/scripts/analyzer/errors/cyclic_inheritance.gd b/modules/gdscript/tests/scripts/analyzer/errors/cyclic_inheritance.gd deleted file mode 100644 index d2f6404cd2b..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/cyclic_inheritance.gd +++ /dev/null @@ -1,8 +0,0 @@ -func test(): - print(InnerA.new()) - -class InnerA extends InnerB: - pass - -class InnerB extends InnerA: - pass diff --git a/modules/gdscript/tests/scripts/analyzer/errors/cyclic_inheritance.out b/modules/gdscript/tests/scripts/analyzer/errors/cyclic_inheritance.out deleted file mode 100644 index c095f679087..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/cyclic_inheritance.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 4: Cyclic inheritance. diff --git a/modules/gdscript/tests/scripts/analyzer/errors/cyclic_ref_const.gd b/modules/gdscript/tests/scripts/analyzer/errors/cyclic_ref_const.gd deleted file mode 100644 index 42925349516..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/cyclic_ref_const.gd +++ /dev/null @@ -1,5 +0,0 @@ -func test(): - print(c1) - -const c1 = c2 -const c2 = c1 diff --git a/modules/gdscript/tests/scripts/analyzer/errors/cyclic_ref_const.out b/modules/gdscript/tests/scripts/analyzer/errors/cyclic_ref_const.out deleted file mode 100644 index 30f0669dbf5..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/cyclic_ref_const.out +++ /dev/null @@ -1,3 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 5: Could not resolve member "c1": Cyclic reference. ->> ERROR at line 5: Could not resolve type for constant "c2". diff --git a/modules/gdscript/tests/scripts/analyzer/errors/cyclic_ref_enum.gd b/modules/gdscript/tests/scripts/analyzer/errors/cyclic_ref_enum.gd deleted file mode 100644 index 1caef3d3664..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/cyclic_ref_enum.gd +++ /dev/null @@ -1,5 +0,0 @@ -func test(): - print(E1.V) - -enum E1 {V = E2.V} -enum E2 {V = E1.V} diff --git a/modules/gdscript/tests/scripts/analyzer/errors/cyclic_ref_enum.out b/modules/gdscript/tests/scripts/analyzer/errors/cyclic_ref_enum.out deleted file mode 100644 index 2d59de75aa8..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/cyclic_ref_enum.out +++ /dev/null @@ -1,3 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 5: Could not resolve member "E1": Cyclic reference. ->> ERROR at line 5: Enum values must be constant. diff --git a/modules/gdscript/tests/scripts/analyzer/errors/cyclic_ref_enum_value.gd b/modules/gdscript/tests/scripts/analyzer/errors/cyclic_ref_enum_value.gd deleted file mode 100644 index 237758f3404..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/cyclic_ref_enum_value.gd +++ /dev/null @@ -1,5 +0,0 @@ -func test(): - print(EV1) - -enum {EV1 = EV2} -enum {EV2 = EV1} diff --git a/modules/gdscript/tests/scripts/analyzer/errors/cyclic_ref_enum_value.out b/modules/gdscript/tests/scripts/analyzer/errors/cyclic_ref_enum_value.out deleted file mode 100644 index 62285ab56f4..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/cyclic_ref_enum_value.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 5: Could not resolve member "EV1": Cyclic reference. diff --git a/modules/gdscript/tests/scripts/analyzer/errors/cyclic_ref_external.gd b/modules/gdscript/tests/scripts/analyzer/errors/cyclic_ref_external.gd deleted file mode 100644 index 52e0d603899..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/cyclic_ref_external.gd +++ /dev/null @@ -1,6 +0,0 @@ -func test(): - print(v) - -var v = A.v - -const A = preload("cyclic_ref_external_a.notest.gd") diff --git a/modules/gdscript/tests/scripts/analyzer/errors/cyclic_ref_external.out b/modules/gdscript/tests/scripts/analyzer/errors/cyclic_ref_external.out deleted file mode 100644 index 80026731fd1..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/cyclic_ref_external.out +++ /dev/null @@ -1,3 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 4: Could not resolve external class member "v". ->> ERROR at line 4: Cannot find member "v" in base "TestCyclicRefExternalA". diff --git a/modules/gdscript/tests/scripts/analyzer/errors/cyclic_ref_external_a.notest.gd b/modules/gdscript/tests/scripts/analyzer/errors/cyclic_ref_external_a.notest.gd deleted file mode 100644 index db6392e416b..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/cyclic_ref_external_a.notest.gd +++ /dev/null @@ -1,5 +0,0 @@ -class_name TestCyclicRefExternalA - -const B = preload("cyclic_ref_external.gd") - -var v = B.v diff --git a/modules/gdscript/tests/scripts/analyzer/errors/cyclic_ref_func.gd b/modules/gdscript/tests/scripts/analyzer/errors/cyclic_ref_func.gd deleted file mode 100644 index b610464c441..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/cyclic_ref_func.gd +++ /dev/null @@ -1,9 +0,0 @@ -func test(): - print(f1()) - print(f2()) - -static func f1(p := f2()) -> int: - return 1 - -static func f2(p := f1()) -> int: - return 2 diff --git a/modules/gdscript/tests/scripts/analyzer/errors/cyclic_ref_func.out b/modules/gdscript/tests/scripts/analyzer/errors/cyclic_ref_func.out deleted file mode 100644 index f060be9d9a7..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/cyclic_ref_func.out +++ /dev/null @@ -1,3 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 8: Could not resolve member "f1": Cyclic reference. ->> ERROR at line 8: Cannot infer the type of "p" parameter because the value doesn't have a set type. diff --git a/modules/gdscript/tests/scripts/analyzer/errors/cyclic_ref_override.gd b/modules/gdscript/tests/scripts/analyzer/errors/cyclic_ref_override.gd deleted file mode 100644 index f7507158386..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/cyclic_ref_override.gd +++ /dev/null @@ -1,12 +0,0 @@ -func test(): - print(v) - -var v := InnerA.new().f() - -class InnerA: - func f(p := InnerB.new().f()) -> int: - return 1 - -class InnerB extends InnerA: - func f(p := 1) -> int: - return super.f() diff --git a/modules/gdscript/tests/scripts/analyzer/errors/cyclic_ref_override.out b/modules/gdscript/tests/scripts/analyzer/errors/cyclic_ref_override.out deleted file mode 100644 index 5f1b608a367..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/cyclic_ref_override.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 11: Could not resolve member "f": Cyclic reference. diff --git a/modules/gdscript/tests/scripts/analyzer/errors/cyclic_ref_var.gd b/modules/gdscript/tests/scripts/analyzer/errors/cyclic_ref_var.gd deleted file mode 100644 index 69138887241..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/cyclic_ref_var.gd +++ /dev/null @@ -1,5 +0,0 @@ -func test(): - print(v1) - -var v1 := v2 -var v2 := v1 diff --git a/modules/gdscript/tests/scripts/analyzer/errors/cyclic_ref_var.out b/modules/gdscript/tests/scripts/analyzer/errors/cyclic_ref_var.out deleted file mode 100644 index f29946bca7b..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/cyclic_ref_var.out +++ /dev/null @@ -1,3 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 5: Could not resolve member "v1": Cyclic reference. ->> ERROR at line 5: Cannot infer the type of "v2" variable because the value doesn't have a set type. diff --git a/modules/gdscript/tests/scripts/analyzer/errors/cyclic_ref_var_self.gd b/modules/gdscript/tests/scripts/analyzer/errors/cyclic_ref_var_self.gd deleted file mode 100644 index 57ae41922f7..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/cyclic_ref_var_self.gd +++ /dev/null @@ -1,4 +0,0 @@ -var v1 = v1 - -func test(): - print(v1) diff --git a/modules/gdscript/tests/scripts/analyzer/errors/cyclic_ref_var_self.out b/modules/gdscript/tests/scripts/analyzer/errors/cyclic_ref_var_self.out deleted file mode 100644 index 77d3f3f2aa7..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/cyclic_ref_var_self.out +++ /dev/null @@ -1,3 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 1: Could not resolve member "v1": Cyclic reference. ->> ERROR at line 1: Could not resolve type for variable "v1". diff --git a/modules/gdscript/tests/scripts/analyzer/errors/cyclic_reference.gd b/modules/gdscript/tests/scripts/analyzer/errors/cyclic_reference.gd new file mode 100644 index 00000000000..459beb803c3 --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/errors/cyclic_reference.gd @@ -0,0 +1,41 @@ +enum NamedEnum0 { VALUE = NamedEnum0.VALUE } +enum NamedEnum1 { VALUE = NamedEnum2.VALUE } +enum NamedEnum2 { VALUE = NamedEnum1.VALUE } + +enum { ENUM_VALUE_0 = ENUM_VALUE_0 } +enum { ENUM_VALUE_1 = ENUM_VALUE_2 } +enum { ENUM_VALUE_2 = ENUM_VALUE_1 } + +const CONST_0 = CONST_0 +const CONST_1 = CONST_2 +const CONST_2 = CONST_1 + +var var_0 = var_0 +var var_1 := var_2 +var var_2 := var_1 + +static func func_0(p := func_0()) -> int: + return 0 +static func func_1(p := func_2()) -> int: + return 1 +static func func_2(p := func_1()) -> int: + return 2 + +var lambda_body = (func (_p): return 0).call(lambda_body_ref) +var lambda_body_ref = lambda_body + +var lambda_param = func (_p = lambda_param_ref): return 0 +var lambda_param_ref = lambda_param + +const External = preload("cyclic_reference.notest.gd") +var member = External.member + +class InnerA: + func f(p := InnerB.new().f()) -> int: + return 1 +class InnerB extends InnerA: + func f(p := 1) -> int: + return super.f() + +func test(): + pass diff --git a/modules/gdscript/tests/scripts/analyzer/errors/cyclic_reference.notest.gd b/modules/gdscript/tests/scripts/analyzer/errors/cyclic_reference.notest.gd new file mode 100644 index 00000000000..61fa2be8e04 --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/errors/cyclic_reference.notest.gd @@ -0,0 +1,5 @@ +class_name TestCyclicRefExternal + +const External = preload("cyclic_reference.gd") + +var member = External.member diff --git a/modules/gdscript/tests/scripts/analyzer/errors/cyclic_reference.out b/modules/gdscript/tests/scripts/analyzer/errors/cyclic_reference.out new file mode 100644 index 00000000000..78b62fd12a7 --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/errors/cyclic_reference.out @@ -0,0 +1,27 @@ +GDTEST_ANALYZER_ERROR +>> ERROR at line 1: Could not resolve member "NamedEnum0": Cyclic reference. +>> ERROR at line 1: Enum values must be constant. +>> ERROR at line 3: Could not resolve member "NamedEnum1": Cyclic reference. +>> ERROR at line 3: Enum values must be constant. +>> ERROR at line 5: Cannot use another enum element before it was declared. +>> ERROR at line 5: Enum values must be constant. +>> ERROR at line 7: Could not resolve member "ENUM_VALUE_1": Cyclic reference. +>> ERROR at line 9: Could not resolve member "CONST_0": Cyclic reference. +>> ERROR at line 9: Could not resolve type for constant "CONST_0". +>> ERROR at line 11: Could not resolve member "CONST_1": Cyclic reference. +>> ERROR at line 11: Could not resolve type for constant "CONST_2". +>> ERROR at line 13: Could not resolve member "var_0": Cyclic reference. +>> ERROR at line 13: Could not resolve type for variable "var_0". +>> ERROR at line 15: Could not resolve member "var_1": Cyclic reference. +>> ERROR at line 15: Cannot infer the type of "var_2" variable because the value doesn't have a set type. +>> ERROR at line 17: Could not resolve member "func_0": Cyclic reference. +>> ERROR at line 17: Cannot infer the type of "p" parameter because the value doesn't have a set type. +>> ERROR at line 21: Could not resolve member "func_1": Cyclic reference. +>> ERROR at line 21: Cannot infer the type of "p" parameter because the value doesn't have a set type. +>> ERROR at line 25: Could not resolve member "lambda_body": Cyclic reference. +>> ERROR at line 25: Could not resolve type for variable "lambda_body_ref". +>> ERROR at line 28: Could not resolve member "lambda_param": Cyclic reference. +>> ERROR at line 28: Could not resolve type for variable "lambda_param_ref". +>> ERROR at line 31: Could not resolve external class member "member". +>> ERROR at line 31: Cannot find member "member" in base "TestCyclicRefExternal". +>> ERROR at line 37: Could not resolve member "f": Cyclic reference. diff --git a/modules/gdscript/tests/scripts/analyzer/errors/dictionary_duplicate_key.gd b/modules/gdscript/tests/scripts/analyzer/errors/dictionary_duplicate_key.gd new file mode 100644 index 00000000000..b23b4ab970b --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/errors/dictionary_duplicate_key.gd @@ -0,0 +1,16 @@ +func test(): + var lua_dict = { + a = 1, + b = 2, + a = 3, # Duplicate isn't allowed. + } + var lua_dict_with_string = { + a = 1, + b = 2, + "a" = 3, # Duplicate isn't allowed. + } + var python_dict = { + "a": 1, + "b": 2, + "a": 3, # Duplicate isn't allowed. + } diff --git a/modules/gdscript/tests/scripts/analyzer/errors/dictionary_duplicate_key.out b/modules/gdscript/tests/scripts/analyzer/errors/dictionary_duplicate_key.out new file mode 100644 index 00000000000..a705b7a0a6b --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/errors/dictionary_duplicate_key.out @@ -0,0 +1,4 @@ +GDTEST_ANALYZER_ERROR +>> ERROR at line 5: Key "a" was already used in this dictionary (at line 3). +>> ERROR at line 10: Key "a" was already used in this dictionary (at line 8). +>> ERROR at line 15: Key "a" was already used in this dictionary (at line 13). diff --git a/modules/gdscript/tests/scripts/analyzer/errors/dictionary_duplicate_key_lua.gd b/modules/gdscript/tests/scripts/analyzer/errors/dictionary_duplicate_key_lua.gd deleted file mode 100644 index 7a922cd73eb..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/dictionary_duplicate_key_lua.gd +++ /dev/null @@ -1,6 +0,0 @@ -func test(): - var lua_dict = { - a = 1, - b = 2, - a = 3, # Duplicate isn't allowed. - } diff --git a/modules/gdscript/tests/scripts/analyzer/errors/dictionary_duplicate_key_lua.out b/modules/gdscript/tests/scripts/analyzer/errors/dictionary_duplicate_key_lua.out deleted file mode 100644 index bc03a633c29..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/dictionary_duplicate_key_lua.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 5: Key "a" was already used in this dictionary (at line 3). diff --git a/modules/gdscript/tests/scripts/analyzer/errors/dictionary_duplicate_key_lua_with_string.gd b/modules/gdscript/tests/scripts/analyzer/errors/dictionary_duplicate_key_lua_with_string.gd deleted file mode 100644 index 933e737ac78..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/dictionary_duplicate_key_lua_with_string.gd +++ /dev/null @@ -1,6 +0,0 @@ -func test(): - var lua_dict_with_string = { - a = 1, - b = 2, - "a" = 3, # Duplicate isn't allowed. - } diff --git a/modules/gdscript/tests/scripts/analyzer/errors/dictionary_duplicate_key_lua_with_string.out b/modules/gdscript/tests/scripts/analyzer/errors/dictionary_duplicate_key_lua_with_string.out deleted file mode 100644 index bc03a633c29..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/dictionary_duplicate_key_lua_with_string.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 5: Key "a" was already used in this dictionary (at line 3). diff --git a/modules/gdscript/tests/scripts/analyzer/errors/dictionary_duplicate_key_python.gd b/modules/gdscript/tests/scripts/analyzer/errors/dictionary_duplicate_key_python.gd deleted file mode 100644 index 3b8c83e9cbc..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/dictionary_duplicate_key_python.gd +++ /dev/null @@ -1,6 +0,0 @@ -func test(): - var python_dict = { - "a": 1, - "b": 2, - "a": 3, # Duplicate isn't allowed. - } diff --git a/modules/gdscript/tests/scripts/analyzer/errors/dictionary_duplicate_key_python.out b/modules/gdscript/tests/scripts/analyzer/errors/dictionary_duplicate_key_python.out deleted file mode 100644 index bc03a633c29..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/dictionary_duplicate_key_python.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 5: Key "a" was already used in this dictionary (at line 3). diff --git a/modules/gdscript/tests/scripts/analyzer/errors/engine_singleton_instantiate.gd b/modules/gdscript/tests/scripts/analyzer/errors/engine_singleton_instantiate.gd deleted file mode 100644 index 7e1efb8d1b4..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/engine_singleton_instantiate.gd +++ /dev/null @@ -1,2 +0,0 @@ -func test(): - Time.new() diff --git a/modules/gdscript/tests/scripts/analyzer/errors/engine_singleton_instantiate.out b/modules/gdscript/tests/scripts/analyzer/errors/engine_singleton_instantiate.out deleted file mode 100644 index 95b4e15aa7b..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/engine_singleton_instantiate.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 2: Cannot construct native class "Time" because it is an engine singleton. diff --git a/modules/gdscript/tests/scripts/analyzer/errors/enum_bad_method.gd b/modules/gdscript/tests/scripts/analyzer/errors/enum_bad_method.gd deleted file mode 100644 index 2940c035154..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/enum_bad_method.gd +++ /dev/null @@ -1,4 +0,0 @@ -enum Enum {V1, V2} - -func test(): - Enum.clear() diff --git a/modules/gdscript/tests/scripts/analyzer/errors/enum_bad_method.out b/modules/gdscript/tests/scripts/analyzer/errors/enum_bad_method.out deleted file mode 100644 index d7c603b86de..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/enum_bad_method.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 4: Cannot call non-const Dictionary function "clear()" on enum "Enum". diff --git a/modules/gdscript/tests/scripts/analyzer/errors/enum_bad_value.gd b/modules/gdscript/tests/scripts/analyzer/errors/enum_bad_value.gd deleted file mode 100644 index a66e2714d9f..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/enum_bad_value.gd +++ /dev/null @@ -1,4 +0,0 @@ -enum Enum {V1, V2} - -func test(): - var bad = Enum.V3 diff --git a/modules/gdscript/tests/scripts/analyzer/errors/enum_bad_value.out b/modules/gdscript/tests/scripts/analyzer/errors/enum_bad_value.out deleted file mode 100644 index a2196871f01..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/enum_bad_value.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 4: Cannot find member "V3" in base "enum_bad_value.gd.Enum". diff --git a/modules/gdscript/tests/scripts/analyzer/errors/enum_builtin_access.gd b/modules/gdscript/tests/scripts/analyzer/errors/enum_builtin_access.gd deleted file mode 100644 index 6367d50980b..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/enum_builtin_access.gd +++ /dev/null @@ -1,2 +0,0 @@ -func test(): - print(Vector3.Axis) diff --git a/modules/gdscript/tests/scripts/analyzer/errors/enum_builtin_access.out b/modules/gdscript/tests/scripts/analyzer/errors/enum_builtin_access.out deleted file mode 100644 index ba13d5429e7..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/enum_builtin_access.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 2: Type "Axis" in base "Vector3" cannot be used on its own. diff --git a/modules/gdscript/tests/scripts/analyzer/errors/enum_class_var_assign_with_wrong_enum_type.gd b/modules/gdscript/tests/scripts/analyzer/errors/enum_class_var_assign_with_wrong_enum_type.gd deleted file mode 100644 index 928c886650c..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/enum_class_var_assign_with_wrong_enum_type.gd +++ /dev/null @@ -1,10 +0,0 @@ -enum MyEnum { ENUM_VALUE_1, ENUM_VALUE_2 } -enum MyOtherEnum { OTHER_ENUM_VALUE_1, OTHER_ENUM_VALUE_2 } - -# Different enum types can't be assigned without casting. -var class_var: MyEnum = MyEnum.ENUM_VALUE_1 - -func test(): - print(class_var) - class_var = MyOtherEnum.OTHER_ENUM_VALUE_2 - print(class_var) diff --git a/modules/gdscript/tests/scripts/analyzer/errors/enum_class_var_assign_with_wrong_enum_type.out b/modules/gdscript/tests/scripts/analyzer/errors/enum_class_var_assign_with_wrong_enum_type.out deleted file mode 100644 index cddb9a40f16..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/enum_class_var_assign_with_wrong_enum_type.out +++ /dev/null @@ -1,3 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 9: Cannot assign a value of type "enum_class_var_assign_with_wrong_enum_type.gd.MyOtherEnum" as "enum_class_var_assign_with_wrong_enum_type.gd.MyEnum". ->> ERROR at line 9: Value of type "enum_class_var_assign_with_wrong_enum_type.gd.MyOtherEnum" cannot be assigned to a variable of type "enum_class_var_assign_with_wrong_enum_type.gd.MyEnum". diff --git a/modules/gdscript/tests/scripts/analyzer/errors/enum_class_var_init_with_wrong_enum_type.gd b/modules/gdscript/tests/scripts/analyzer/errors/enum_class_var_init_with_wrong_enum_type.gd deleted file mode 100644 index 03a1711d7b4..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/enum_class_var_init_with_wrong_enum_type.gd +++ /dev/null @@ -1,8 +0,0 @@ -enum MyEnum { ENUM_VALUE_1, ENUM_VALUE_2 } -enum MyOtherEnum { OTHER_ENUM_VALUE_1, OTHER_ENUM_VALUE_2 } - -# Different enum types can't be assigned without casting. -var class_var: MyEnum = MyOtherEnum.OTHER_ENUM_VALUE_1 - -func test(): - print(class_var) diff --git a/modules/gdscript/tests/scripts/analyzer/errors/enum_class_var_init_with_wrong_enum_type.out b/modules/gdscript/tests/scripts/analyzer/errors/enum_class_var_init_with_wrong_enum_type.out deleted file mode 100644 index 8b53d95446f..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/enum_class_var_init_with_wrong_enum_type.out +++ /dev/null @@ -1,3 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 5: Cannot assign a value of type "enum_class_var_init_with_wrong_enum_type.gd.MyOtherEnum" as "enum_class_var_init_with_wrong_enum_type.gd.MyEnum". ->> ERROR at line 5: Cannot assign a value of type enum_class_var_init_with_wrong_enum_type.gd.MyOtherEnum to variable "class_var" with specified type enum_class_var_init_with_wrong_enum_type.gd.MyEnum. diff --git a/modules/gdscript/tests/scripts/analyzer/errors/enum_declaration_and_usage.gd b/modules/gdscript/tests/scripts/analyzer/errors/enum_declaration_and_usage.gd new file mode 100644 index 00000000000..1843ff1261f --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/errors/enum_declaration_and_usage.gd @@ -0,0 +1,28 @@ +enum BadEnum { + A = 0.0, + B = "hello", +} + +enum CustomEnum { A, B } + +func test(): + print(Variant.Operator) # Global. + print(Vector3.Axis) # Built-in. + print(Node.ProcessMode) # Native. + + print(Side.NOT_EXIST) # Global. + print(Vector3.Axis.NOT_EXIST) # Built-in. + print(TileSet.TileShape.NOT_EXIST) # Native. + print(CustomEnum.NOT_EXIST) # Custom. + + print(Side.size()) # Global. + print(Vector3.Axis.size()) # Built-in. + print(TileSet.TileShape.size()) # Native. + + Side.clear() # Global. + Vector3.Axis.clear() # Built-in. + TileSet.TileShape.clear() # Native. + CustomEnum.clear() # Custom. + + var enum_type = CustomEnum + enum_type.clear() diff --git a/modules/gdscript/tests/scripts/analyzer/errors/enum_declaration_and_usage.out b/modules/gdscript/tests/scripts/analyzer/errors/enum_declaration_and_usage.out new file mode 100644 index 00000000000..404bc01e7b2 --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/errors/enum_declaration_and_usage.out @@ -0,0 +1,30 @@ +GDTEST_ANALYZER_ERROR +>> ERROR at line 2: Enum values must be integers. +>> ERROR at line 3: Enum values must be integers. +>> ERROR at line 9: Type "Operator" in base "Variant" cannot be used on its own. +>> ERROR at line 10: Type "Axis" in base "Vector3" cannot be used on its own. +>> ERROR at line 11: Type "ProcessMode" in base "Node" cannot be used on its own. +>> ERROR at line 13: Cannot find member "NOT_EXIST" in base "Side". +>> ERROR at line 14: Cannot find member "NOT_EXIST" in base "Vector3.Axis". +>> ERROR at line 15: Cannot find member "NOT_EXIST" in base "TileSet.TileShape". +>> ERROR at line 16: Cannot find member "NOT_EXIST" in base "enum_declaration_and_usage.gd.CustomEnum". +>> ERROR at line 18: Global enum "Side" cannot be used on its own. +>> ERROR at line 18: The native enum "Side" does not behave like Dictionary and does not have methods of its own. +>> ERROR at line 18: Static function "size()" not found in base "Side". +>> ERROR at line 19: Type "Axis" in base "Vector3" cannot be used on its own. +>> ERROR at line 19: Native class Vector3.Axis used in script doesn't exist or isn't exposed. +>> ERROR at line 19: Static function "size()" not found in base "Variant". +>> ERROR at line 20: Type "TileShape" in base "TileSet" cannot be used on its own. +>> ERROR at line 20: Native class TileSet.TileShape used in script doesn't exist or isn't exposed. +>> ERROR at line 20: Static function "size()" not found in base "Variant". +>> ERROR at line 22: Global enum "Side" cannot be used on its own. +>> ERROR at line 22: The native enum "Side" does not behave like Dictionary and does not have methods of its own. +>> ERROR at line 22: Static function "clear()" not found in base "Side". +>> ERROR at line 23: Type "Axis" in base "Vector3" cannot be used on its own. +>> ERROR at line 23: Native class Vector3.Axis used in script doesn't exist or isn't exposed. +>> ERROR at line 23: Static function "clear()" not found in base "Variant". +>> ERROR at line 24: Type "TileShape" in base "TileSet" cannot be used on its own. +>> ERROR at line 24: Native class TileSet.TileShape used in script doesn't exist or isn't exposed. +>> ERROR at line 24: Static function "clear()" not found in base "Variant". +>> ERROR at line 25: Cannot call non-const Dictionary function "clear()" on enum "CustomEnum". +>> ERROR at line 28: Cannot call non-const Dictionary function "clear()" on enum "CustomEnum". diff --git a/modules/gdscript/tests/scripts/analyzer/errors/enum_duplicate_bad_method.gd b/modules/gdscript/tests/scripts/analyzer/errors/enum_duplicate_bad_method.gd deleted file mode 100644 index 2c7dfafd060..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/enum_duplicate_bad_method.gd +++ /dev/null @@ -1,5 +0,0 @@ -enum Enum {V1, V2} - -func test(): - var Enum2 = Enum - Enum2.clear() diff --git a/modules/gdscript/tests/scripts/analyzer/errors/enum_duplicate_bad_method.out b/modules/gdscript/tests/scripts/analyzer/errors/enum_duplicate_bad_method.out deleted file mode 100644 index 2a2554db8b3..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/enum_duplicate_bad_method.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 5: Cannot call non-const Dictionary function "clear()" on enum "Enum". diff --git a/modules/gdscript/tests/scripts/analyzer/errors/enum_float_value.gd b/modules/gdscript/tests/scripts/analyzer/errors/enum_float_value.gd deleted file mode 100644 index cf9a0ce038d..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/enum_float_value.gd +++ /dev/null @@ -1,7 +0,0 @@ -enum Size { - # Error here. Enum values must be integers. - S = 0.0, -} - -func test(): - pass diff --git a/modules/gdscript/tests/scripts/analyzer/errors/enum_float_value.out b/modules/gdscript/tests/scripts/analyzer/errors/enum_float_value.out deleted file mode 100644 index 6d9be86593f..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/enum_float_value.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 3: Enum values must be integers. diff --git a/modules/gdscript/tests/scripts/analyzer/errors/enum_function_parameter_wrong_type.gd b/modules/gdscript/tests/scripts/analyzer/errors/enum_function_parameter_wrong_type.gd deleted file mode 100644 index 900155569cd..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/enum_function_parameter_wrong_type.gd +++ /dev/null @@ -1,8 +0,0 @@ -enum MyEnum { ENUM_VALUE_1, ENUM_VALUE_2 } -enum MyOtherEnum { OTHER_ENUM_VALUE_1, OTHER_ENUM_VALUE_2 } - -func enum_func(e: MyEnum) -> void: - print(e) - -func test(): - enum_func(MyOtherEnum.OTHER_ENUM_VALUE_1) diff --git a/modules/gdscript/tests/scripts/analyzer/errors/enum_function_parameter_wrong_type.out b/modules/gdscript/tests/scripts/analyzer/errors/enum_function_parameter_wrong_type.out deleted file mode 100644 index 35cdbef72f9..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/enum_function_parameter_wrong_type.out +++ /dev/null @@ -1,3 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 8: Cannot pass a value of type "enum_function_parameter_wrong_type.gd.MyOtherEnum" as "enum_function_parameter_wrong_type.gd.MyEnum". ->> ERROR at line 8: Invalid argument for "enum_func()" function: argument 1 should be "enum_function_parameter_wrong_type.gd.MyEnum" but is "enum_function_parameter_wrong_type.gd.MyOtherEnum". diff --git a/modules/gdscript/tests/scripts/analyzer/errors/enum_function_return_wrong_type.gd b/modules/gdscript/tests/scripts/analyzer/errors/enum_function_return_wrong_type.gd deleted file mode 100644 index 18b3ffb0fce..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/enum_function_return_wrong_type.gd +++ /dev/null @@ -1,8 +0,0 @@ -enum MyEnum { ENUM_VALUE_1, ENUM_VALUE_2 } -enum MyOtherEnum { OTHER_ENUM_VALUE_1, OTHER_ENUM_VALUE_2 } - -func enum_func() -> MyEnum: - return MyOtherEnum.OTHER_ENUM_VALUE_1 - -func test(): - print(enum_func()) diff --git a/modules/gdscript/tests/scripts/analyzer/errors/enum_function_return_wrong_type.out b/modules/gdscript/tests/scripts/analyzer/errors/enum_function_return_wrong_type.out deleted file mode 100644 index 2eb17d5889a..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/enum_function_return_wrong_type.out +++ /dev/null @@ -1,3 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 5: Cannot return a value of type "enum_function_return_wrong_type.gd.MyOtherEnum" as "enum_function_return_wrong_type.gd.MyEnum". ->> ERROR at line 5: Cannot return value of type "enum_function_return_wrong_type.gd.MyOtherEnum" because the function return type is "enum_function_return_wrong_type.gd.MyEnum". diff --git a/modules/gdscript/tests/scripts/analyzer/errors/enum_global_access.gd b/modules/gdscript/tests/scripts/analyzer/errors/enum_global_access.gd deleted file mode 100644 index badcd3a83cf..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/enum_global_access.gd +++ /dev/null @@ -1,2 +0,0 @@ -func test(): - print(Variant.Operator) diff --git a/modules/gdscript/tests/scripts/analyzer/errors/enum_global_access.out b/modules/gdscript/tests/scripts/analyzer/errors/enum_global_access.out deleted file mode 100644 index a7b9c205ad5..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/enum_global_access.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 2: Type "Operator" in base "Variant" cannot be used on its own. diff --git a/modules/gdscript/tests/scripts/analyzer/errors/enum_local_var_assign_outer_with_wrong_enum_type.gd b/modules/gdscript/tests/scripts/analyzer/errors/enum_local_var_assign_outer_with_wrong_enum_type.gd deleted file mode 100644 index 2b006f1f698..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/enum_local_var_assign_outer_with_wrong_enum_type.gd +++ /dev/null @@ -1,10 +0,0 @@ -enum MyEnum { ENUM_VALUE_1, ENUM_VALUE_2 } - -class InnerClass: - enum MyEnum { ENUM_VALUE_1, ENUM_VALUE_2 } - -func test(): - var local_var: MyEnum = MyEnum.ENUM_VALUE_1 - print(local_var) - local_var = InnerClass.MyEnum.ENUM_VALUE_2 - print(local_var) diff --git a/modules/gdscript/tests/scripts/analyzer/errors/enum_local_var_assign_outer_with_wrong_enum_type.out b/modules/gdscript/tests/scripts/analyzer/errors/enum_local_var_assign_outer_with_wrong_enum_type.out deleted file mode 100644 index d5043e188fa..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/enum_local_var_assign_outer_with_wrong_enum_type.out +++ /dev/null @@ -1,3 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 9: Cannot assign a value of type "enum_local_var_assign_outer_with_wrong_enum_type.gd::InnerClass.MyEnum" as "enum_local_var_assign_outer_with_wrong_enum_type.gd.MyEnum". ->> ERROR at line 9: Value of type "enum_local_var_assign_outer_with_wrong_enum_type.gd::InnerClass.MyEnum" cannot be assigned to a variable of type "enum_local_var_assign_outer_with_wrong_enum_type.gd.MyEnum". diff --git a/modules/gdscript/tests/scripts/analyzer/errors/enum_local_var_assign_with_wrong_enum_type.gd b/modules/gdscript/tests/scripts/analyzer/errors/enum_local_var_assign_with_wrong_enum_type.gd deleted file mode 100644 index d08d3dd7b28..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/enum_local_var_assign_with_wrong_enum_type.gd +++ /dev/null @@ -1,8 +0,0 @@ -enum MyEnum { ENUM_VALUE_1, ENUM_VALUE_2 } -enum MyOtherEnum { OTHER_ENUM_VALUE_1, OTHER_ENUM_VALUE_2 } - -func test(): - var local_var: MyEnum = MyEnum.ENUM_VALUE_1 - print(local_var) - local_var = MyOtherEnum.OTHER_ENUM_VALUE_2 - print(local_var) diff --git a/modules/gdscript/tests/scripts/analyzer/errors/enum_local_var_assign_with_wrong_enum_type.out b/modules/gdscript/tests/scripts/analyzer/errors/enum_local_var_assign_with_wrong_enum_type.out deleted file mode 100644 index ceb6eab0092..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/enum_local_var_assign_with_wrong_enum_type.out +++ /dev/null @@ -1,3 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 7: Cannot assign a value of type "enum_local_var_assign_with_wrong_enum_type.gd.MyOtherEnum" as "enum_local_var_assign_with_wrong_enum_type.gd.MyEnum". ->> ERROR at line 7: Value of type "enum_local_var_assign_with_wrong_enum_type.gd.MyOtherEnum" cannot be assigned to a variable of type "enum_local_var_assign_with_wrong_enum_type.gd.MyEnum". diff --git a/modules/gdscript/tests/scripts/analyzer/errors/enum_local_var_init_with_wrong_enum_type.gd b/modules/gdscript/tests/scripts/analyzer/errors/enum_local_var_init_with_wrong_enum_type.gd deleted file mode 100644 index ca6d892218c..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/enum_local_var_init_with_wrong_enum_type.gd +++ /dev/null @@ -1,6 +0,0 @@ -enum MyEnum { ENUM_VALUE_1, ENUM_VALUE_2 } -enum MyOtherEnum { OTHER_ENUM_VALUE_1, OTHER_ENUM_VALUE_2 } - -func test(): - var local_var: MyEnum = MyOtherEnum.OTHER_ENUM_VALUE_1 - print(local_var) diff --git a/modules/gdscript/tests/scripts/analyzer/errors/enum_local_var_init_with_wrong_enum_type.out b/modules/gdscript/tests/scripts/analyzer/errors/enum_local_var_init_with_wrong_enum_type.out deleted file mode 100644 index fccd612baec..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/enum_local_var_init_with_wrong_enum_type.out +++ /dev/null @@ -1,3 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 5: Cannot assign a value of type "enum_local_var_init_with_wrong_enum_type.gd.MyOtherEnum" as "enum_local_var_init_with_wrong_enum_type.gd.MyEnum". ->> ERROR at line 5: Cannot assign a value of type enum_local_var_init_with_wrong_enum_type.gd.MyOtherEnum to variable "local_var" with specified type enum_local_var_init_with_wrong_enum_type.gd.MyEnum. diff --git a/modules/gdscript/tests/scripts/analyzer/errors/enum_name_shadows_builtin_type.gd b/modules/gdscript/tests/scripts/analyzer/errors/enum_name_shadows_builtin_type.gd deleted file mode 100644 index 930f91b3894..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/enum_name_shadows_builtin_type.gd +++ /dev/null @@ -1,4 +0,0 @@ -enum Vector2 { A, B } - -func test(): - pass diff --git a/modules/gdscript/tests/scripts/analyzer/errors/enum_name_shadows_builtin_type.out b/modules/gdscript/tests/scripts/analyzer/errors/enum_name_shadows_builtin_type.out deleted file mode 100644 index ce8d9807b2f..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/enum_name_shadows_builtin_type.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 1: The member "Vector2" cannot have the same name as a builtin type. diff --git a/modules/gdscript/tests/scripts/analyzer/errors/enum_native_access.gd b/modules/gdscript/tests/scripts/analyzer/errors/enum_native_access.gd deleted file mode 100644 index e07998ddf65..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/enum_native_access.gd +++ /dev/null @@ -1,2 +0,0 @@ -func test(): - print(Node.ProcessMode) diff --git a/modules/gdscript/tests/scripts/analyzer/errors/enum_native_access.out b/modules/gdscript/tests/scripts/analyzer/errors/enum_native_access.out deleted file mode 100644 index 43e650e4c64..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/enum_native_access.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 2: Type "ProcessMode" in base "Node" cannot be used on its own. diff --git a/modules/gdscript/tests/scripts/analyzer/errors/enum_native_bad_value.gd b/modules/gdscript/tests/scripts/analyzer/errors/enum_native_bad_value.gd deleted file mode 100644 index 744c2e47ced..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/enum_native_bad_value.gd +++ /dev/null @@ -1,2 +0,0 @@ -func test(): - var _bad = TileSet.TileShape.THIS_DOES_NOT_EXIST diff --git a/modules/gdscript/tests/scripts/analyzer/errors/enum_native_bad_value.out b/modules/gdscript/tests/scripts/analyzer/errors/enum_native_bad_value.out deleted file mode 100644 index 1af8b3e283d..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/enum_native_bad_value.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 2: Cannot find member "THIS_DOES_NOT_EXIST" in base "TileSet.TileShape". diff --git a/modules/gdscript/tests/scripts/analyzer/errors/enum_preload_unnamed_assign_to_named.gd b/modules/gdscript/tests/scripts/analyzer/errors/enum_preload_unnamed_assign_to_named.gd deleted file mode 100644 index 81d5d59ae8e..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/enum_preload_unnamed_assign_to_named.gd +++ /dev/null @@ -1,7 +0,0 @@ -enum MyEnum { VALUE_A, VALUE_B, VALUE_C = 42 } - -func test(): - const P = preload("../features/enum_value_from_parent.gd") - var local_var: MyEnum - local_var = P.VALUE_B - print(local_var) diff --git a/modules/gdscript/tests/scripts/analyzer/errors/enum_preload_unnamed_assign_to_named.out b/modules/gdscript/tests/scripts/analyzer/errors/enum_preload_unnamed_assign_to_named.out deleted file mode 100644 index d24d294f084..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/enum_preload_unnamed_assign_to_named.out +++ /dev/null @@ -1,3 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 6: Cannot assign a value of type "enum_value_from_parent.gd." as "enum_preload_unnamed_assign_to_named.gd.MyEnum". ->> ERROR at line 6: Value of type "enum_value_from_parent.gd." cannot be assigned to a variable of type "enum_preload_unnamed_assign_to_named.gd.MyEnum". diff --git a/modules/gdscript/tests/scripts/analyzer/errors/enum_shadows_base_enum.gd b/modules/gdscript/tests/scripts/analyzer/errors/enum_shadows_base_enum.gd deleted file mode 100644 index 96904c297aa..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/enum_shadows_base_enum.gd +++ /dev/null @@ -1,8 +0,0 @@ -class A: - enum { V } - -class B extends A: - enum { V } - -func test(): - pass diff --git a/modules/gdscript/tests/scripts/analyzer/errors/enum_shadows_base_enum.out b/modules/gdscript/tests/scripts/analyzer/errors/enum_shadows_base_enum.out deleted file mode 100644 index 8c599ac6d88..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/enum_shadows_base_enum.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 5: The member "V" already exists in parent class A. diff --git a/modules/gdscript/tests/scripts/analyzer/errors/enum_string_value.gd b/modules/gdscript/tests/scripts/analyzer/errors/enum_string_value.gd deleted file mode 100644 index cd9b8fabc47..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/enum_string_value.gd +++ /dev/null @@ -1,7 +0,0 @@ -enum Size { - # Error here. Enum values must be integers. - S = "hello", -} - -func test(): - pass diff --git a/modules/gdscript/tests/scripts/analyzer/errors/enum_string_value.out b/modules/gdscript/tests/scripts/analyzer/errors/enum_string_value.out deleted file mode 100644 index 6d9be86593f..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/enum_string_value.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 3: Enum values must be integers. diff --git a/modules/gdscript/tests/scripts/analyzer/errors/enum_type_checking.gd b/modules/gdscript/tests/scripts/analyzer/errors/enum_type_checking.gd new file mode 100644 index 00000000000..a60caff1ba0 --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/errors/enum_type_checking.gd @@ -0,0 +1,39 @@ +class InnerClass: + enum MyEnum { ENUM_VALUE_1, ENUM_VALUE_2 } + +enum MyEnum { ENUM_VALUE_1, ENUM_VALUE_2 } +enum MyOtherEnum { OTHER_ENUM_VALUE_1, OTHER_ENUM_VALUE_2 } + +enum { ENUM_VALUE_1, ENUM_VALUE_2 } + +var class_var_1: MyEnum = MyOtherEnum.OTHER_ENUM_VALUE_1 +var class_var_2: MyEnum + +func enum_func_1(e: MyEnum) -> void: + print(e) + +func enum_func_2() -> MyEnum: + return MyOtherEnum.OTHER_ENUM_VALUE_1 + +func test(): + class_var_2 = MyOtherEnum.OTHER_ENUM_VALUE_2 + + var local_var_1: MyEnum = MyOtherEnum.OTHER_ENUM_VALUE_1 + + var local_var_2: MyEnum + local_var_2 = MyOtherEnum.OTHER_ENUM_VALUE_2 + + var local_var_3: MyEnum + local_var_3 = InnerClass.MyEnum.ENUM_VALUE_2 + + var local_var_4: MyEnum = ENUM_VALUE_1 + + const P1 = preload("../features/enum_from_outer.gd") + var local_var_5: MyEnum + local_var_5 = P1.Named.VALUE_A + + const P2 = preload("../features/enum_value_from_parent.gd") + var local_var_6: MyEnum + local_var_6 = P2.VALUE_B + + enum_func_1(MyOtherEnum.OTHER_ENUM_VALUE_1) diff --git a/modules/gdscript/tests/scripts/analyzer/errors/enum_type_checking.out b/modules/gdscript/tests/scripts/analyzer/errors/enum_type_checking.out new file mode 100644 index 00000000000..d8af833c84d --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/errors/enum_type_checking.out @@ -0,0 +1,21 @@ +GDTEST_ANALYZER_ERROR +>> ERROR at line 9: Cannot assign a value of type "enum_type_checking.gd.MyOtherEnum" as "enum_type_checking.gd.MyEnum". +>> ERROR at line 9: Cannot assign a value of type enum_type_checking.gd.MyOtherEnum to variable "class_var_1" with specified type enum_type_checking.gd.MyEnum. +>> ERROR at line 16: Cannot return a value of type "enum_type_checking.gd.MyOtherEnum" as "enum_type_checking.gd.MyEnum". +>> ERROR at line 16: Cannot return value of type "enum_type_checking.gd.MyOtherEnum" because the function return type is "enum_type_checking.gd.MyEnum". +>> ERROR at line 19: Cannot assign a value of type "enum_type_checking.gd.MyOtherEnum" as "enum_type_checking.gd.MyEnum". +>> ERROR at line 19: Value of type "enum_type_checking.gd.MyOtherEnum" cannot be assigned to a variable of type "enum_type_checking.gd.MyEnum". +>> ERROR at line 21: Cannot assign a value of type "enum_type_checking.gd.MyOtherEnum" as "enum_type_checking.gd.MyEnum". +>> ERROR at line 21: Cannot assign a value of type enum_type_checking.gd.MyOtherEnum to variable "local_var_1" with specified type enum_type_checking.gd.MyEnum. +>> ERROR at line 24: Cannot assign a value of type "enum_type_checking.gd.MyOtherEnum" as "enum_type_checking.gd.MyEnum". +>> ERROR at line 24: Value of type "enum_type_checking.gd.MyOtherEnum" cannot be assigned to a variable of type "enum_type_checking.gd.MyEnum". +>> ERROR at line 27: Cannot assign a value of type "enum_type_checking.gd::InnerClass.MyEnum" as "enum_type_checking.gd.MyEnum". +>> ERROR at line 27: Value of type "enum_type_checking.gd::InnerClass.MyEnum" cannot be assigned to a variable of type "enum_type_checking.gd.MyEnum". +>> ERROR at line 29: Cannot assign a value of type "enum_type_checking.gd." as "enum_type_checking.gd.MyEnum". +>> ERROR at line 29: Cannot assign a value of type enum_type_checking.gd. to variable "local_var_4" with specified type enum_type_checking.gd.MyEnum. +>> ERROR at line 33: Cannot assign a value of type "enum_from_outer.gd.Named" as "enum_type_checking.gd.MyEnum". +>> ERROR at line 33: Value of type "enum_from_outer.gd.Named" cannot be assigned to a variable of type "enum_type_checking.gd.MyEnum". +>> ERROR at line 37: Cannot assign a value of type "enum_value_from_parent.gd." as "enum_type_checking.gd.MyEnum". +>> ERROR at line 37: Value of type "enum_value_from_parent.gd." cannot be assigned to a variable of type "enum_type_checking.gd.MyEnum". +>> ERROR at line 39: Cannot pass a value of type "enum_type_checking.gd.MyOtherEnum" as "enum_type_checking.gd.MyEnum". +>> ERROR at line 39: Invalid argument for "enum_func_1()" function: argument 1 should be "enum_type_checking.gd.MyEnum" but is "enum_type_checking.gd.MyOtherEnum". diff --git a/modules/gdscript/tests/scripts/analyzer/errors/enum_unnamed_assign_to_named.gd b/modules/gdscript/tests/scripts/analyzer/errors/enum_unnamed_assign_to_named.gd deleted file mode 100644 index 7e749db6b5b..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/enum_unnamed_assign_to_named.gd +++ /dev/null @@ -1,7 +0,0 @@ -enum { ENUM_VALUE_1, ENUM_VALUE_2 } - -enum MyEnum { ENUM_VALUE_1, ENUM_VALUE_2 } - -func test(): - var local_var: MyEnum = ENUM_VALUE_1 - print(local_var) diff --git a/modules/gdscript/tests/scripts/analyzer/errors/enum_unnamed_assign_to_named.out b/modules/gdscript/tests/scripts/analyzer/errors/enum_unnamed_assign_to_named.out deleted file mode 100644 index 69ea54370c3..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/enum_unnamed_assign_to_named.out +++ /dev/null @@ -1,3 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 6: Cannot assign a value of type "enum_unnamed_assign_to_named.gd." as "enum_unnamed_assign_to_named.gd.MyEnum". ->> ERROR at line 6: Cannot assign a value of type enum_unnamed_assign_to_named.gd. to variable "local_var" with specified type enum_unnamed_assign_to_named.gd.MyEnum. diff --git a/modules/gdscript/tests/scripts/analyzer/errors/export_node_in_non_node_derived_class.gd b/modules/gdscript/tests/scripts/analyzer/errors/export_node_in_non_node_derived_class.gd new file mode 100644 index 00000000000..aaee594bf52 --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/errors/export_node_in_non_node_derived_class.gd @@ -0,0 +1,10 @@ +# GH-82809 + +extends Node + +class MyResource extends Resource: + @export var node: Node + @export var node_array: Array[Node] + +func test(): + pass diff --git a/modules/gdscript/tests/scripts/analyzer/errors/export_node_in_non_node_derived_class.out b/modules/gdscript/tests/scripts/analyzer/errors/export_node_in_non_node_derived_class.out new file mode 100644 index 00000000000..e16fa4f6338 --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/errors/export_node_in_non_node_derived_class.out @@ -0,0 +1,3 @@ +GDTEST_ANALYZER_ERROR +>> ERROR at line 6: Node export is only supported in Node-derived classes, but the current class inherits "Resource". +>> ERROR at line 7: Node export is only supported in Node-derived classes, but the current class inherits "Resource". diff --git a/modules/gdscript/tests/scripts/analyzer/errors/export_node_in_non_node_derived_class_1.gd b/modules/gdscript/tests/scripts/analyzer/errors/export_node_in_non_node_derived_class_1.gd deleted file mode 100644 index 05aa726a050..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/export_node_in_non_node_derived_class_1.gd +++ /dev/null @@ -1,8 +0,0 @@ -# GH-82809 - -extends Resource - -@export var node: Node - -func test(): - pass diff --git a/modules/gdscript/tests/scripts/analyzer/errors/export_node_in_non_node_derived_class_1.out b/modules/gdscript/tests/scripts/analyzer/errors/export_node_in_non_node_derived_class_1.out deleted file mode 100644 index 1ca9bd82fc5..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/export_node_in_non_node_derived_class_1.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 5: Node export is only supported in Node-derived classes, but the current class inherits "Resource". diff --git a/modules/gdscript/tests/scripts/analyzer/errors/export_node_in_non_node_derived_class_2.gd b/modules/gdscript/tests/scripts/analyzer/errors/export_node_in_non_node_derived_class_2.gd deleted file mode 100644 index c210e7c043b..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/export_node_in_non_node_derived_class_2.gd +++ /dev/null @@ -1,9 +0,0 @@ -# GH-82809 - -extends Node - -class Inner: - @export var node: Node - -func test(): - pass diff --git a/modules/gdscript/tests/scripts/analyzer/errors/export_node_in_non_node_derived_class_2.out b/modules/gdscript/tests/scripts/analyzer/errors/export_node_in_non_node_derived_class_2.out deleted file mode 100644 index 8bffe49dd0c..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/export_node_in_non_node_derived_class_2.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 6: Node export is only supported in Node-derived classes, but the current class inherits "RefCounted". diff --git a/modules/gdscript/tests/scripts/analyzer/errors/export_node_in_non_node_derived_class_3.gd b/modules/gdscript/tests/scripts/analyzer/errors/export_node_in_non_node_derived_class_3.gd deleted file mode 100644 index 6f2c1046437..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/export_node_in_non_node_derived_class_3.gd +++ /dev/null @@ -1,8 +0,0 @@ -# GH-82809 - -extends Resource - -@export var node_array: Array[Node] - -func test(): - pass diff --git a/modules/gdscript/tests/scripts/analyzer/errors/export_node_in_non_node_derived_class_3.out b/modules/gdscript/tests/scripts/analyzer/errors/export_node_in_non_node_derived_class_3.out deleted file mode 100644 index 1ca9bd82fc5..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/export_node_in_non_node_derived_class_3.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 5: Node export is only supported in Node-derived classes, but the current class inherits "Resource". diff --git a/modules/gdscript/tests/scripts/analyzer/errors/extend_engine_singleton.gd b/modules/gdscript/tests/scripts/analyzer/errors/extend_engine_singleton.gd deleted file mode 100644 index a46b6d8658b..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/extend_engine_singleton.gd +++ /dev/null @@ -1,6 +0,0 @@ -# GH-82081 - -extends Time - -func test(): - pass diff --git a/modules/gdscript/tests/scripts/analyzer/errors/extend_engine_singleton.out b/modules/gdscript/tests/scripts/analyzer/errors/extend_engine_singleton.out deleted file mode 100644 index 6f739d72bf3..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/extend_engine_singleton.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 3: Cannot inherit native class "Time" because it is an engine singleton. diff --git a/modules/gdscript/tests/scripts/analyzer/errors/extend_non_class_constant_1.gd b/modules/gdscript/tests/scripts/analyzer/errors/extend_non_class_constant_1.gd deleted file mode 100644 index 72af0991587..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/extend_non_class_constant_1.gd +++ /dev/null @@ -1,9 +0,0 @@ -# GH-75870 - -const A = 1 - -class B extends A: - pass - -func test(): - pass diff --git a/modules/gdscript/tests/scripts/analyzer/errors/extend_non_class_constant_1.out b/modules/gdscript/tests/scripts/analyzer/errors/extend_non_class_constant_1.out deleted file mode 100644 index 55d711de82c..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/extend_non_class_constant_1.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 5: Constant "A" is not a preloaded script or class. diff --git a/modules/gdscript/tests/scripts/analyzer/errors/extend_non_class_constant_2.gd b/modules/gdscript/tests/scripts/analyzer/errors/extend_non_class_constant_2.gd deleted file mode 100644 index fe334f8cb77..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/extend_non_class_constant_2.gd +++ /dev/null @@ -1,12 +0,0 @@ -# GH-75870 - -class A: - const X = 1 - -const Y = A.X # A.X is now resolved. - -class B extends A.X: - pass - -func test(): - pass diff --git a/modules/gdscript/tests/scripts/analyzer/errors/extend_non_class_constant_2.out b/modules/gdscript/tests/scripts/analyzer/errors/extend_non_class_constant_2.out deleted file mode 100644 index cf55c12855b..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/extend_non_class_constant_2.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 8: Identifier "X" is not a preloaded script or class. diff --git a/modules/gdscript/tests/scripts/analyzer/errors/extend_non_gdscript_nested.gd b/modules/gdscript/tests/scripts/analyzer/errors/extend_non_gdscript_nested.gd deleted file mode 100644 index 54cf4d89ec4..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/extend_non_gdscript_nested.gd +++ /dev/null @@ -1,5 +0,0 @@ -class Foo extends RefCounted.Bar: - pass - -func test(): - print('not ok') diff --git a/modules/gdscript/tests/scripts/analyzer/errors/extend_non_gdscript_nested.out b/modules/gdscript/tests/scripts/analyzer/errors/extend_non_gdscript_nested.out deleted file mode 100644 index 0200a117aec..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/extend_non_gdscript_nested.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 1: Cannot get nested types for extension from non-GDScript type "RefCounted". diff --git a/modules/gdscript/tests/scripts/analyzer/errors/extend_unknown.gd b/modules/gdscript/tests/scripts/analyzer/errors/extend_unknown.gd deleted file mode 100644 index 0f7d584edbb..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/extend_unknown.gd +++ /dev/null @@ -1,8 +0,0 @@ -class Foo: - pass - -class Bar extends Foo.Baz: - pass - -func test(): - print('not ok') diff --git a/modules/gdscript/tests/scripts/analyzer/errors/extend_unknown.out b/modules/gdscript/tests/scripts/analyzer/errors/extend_unknown.out deleted file mode 100644 index 35361d5685f..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/extend_unknown.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 4: Could not find nested type "Baz". diff --git a/modules/gdscript/tests/scripts/analyzer/errors/extend_variable.gd b/modules/gdscript/tests/scripts/analyzer/errors/extend_variable.gd deleted file mode 100644 index 6574d4cf31c..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/extend_variable.gd +++ /dev/null @@ -1,9 +0,0 @@ -# GH-75870 - -var A = 1 - -class B extends A: - pass - -func test(): - pass diff --git a/modules/gdscript/tests/scripts/analyzer/errors/extend_variable.out b/modules/gdscript/tests/scripts/analyzer/errors/extend_variable.out deleted file mode 100644 index 7baa02be9b1..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/extend_variable.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 5: Cannot use variable "A" in extends chain. diff --git a/modules/gdscript/tests/scripts/analyzer/errors/for_loop_inferred_type.gd b/modules/gdscript/tests/scripts/analyzer/errors/for_loop_inferred_type.gd new file mode 100644 index 00000000000..94425a78ff1 --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/errors/for_loop_inferred_type.gd @@ -0,0 +1,59 @@ +class Iterator: + func _iter_init(_count): + return true + func _iter_next(_count): + return false + func _iter_get(_count) -> StringName: + return &"custom" + +enum { ENUM_VALUE = 1 } + +func test(): + # Literals. + + for x in true: + pass + + for x in 1: + if x is String: + pass + + # Constants. + + const CONSTANT_INT = 1 + for x in CONSTANT_INT: + if x is String: + pass + + const CONSTANT_FLOAT = 1.0 + for x in CONSTANT_FLOAT: + if x is String: + pass + + # Hard types. + + var hard_int := 1 + for x in hard_int: + if x is String: + pass + + var hard_float := 1.0 + for x in hard_float: + if x is String: + pass + + var hard_string := "a" + for x in hard_string: + if x is int: + pass + + # Other. + + for x in ENUM_VALUE: + if x is String: + pass + + var hard_iterator := Iterator.new() + for x in hard_iterator: + if x is int: + pass diff --git a/modules/gdscript/tests/scripts/analyzer/errors/for_loop_inferred_type.out b/modules/gdscript/tests/scripts/analyzer/errors/for_loop_inferred_type.out new file mode 100644 index 00000000000..bced3fb9c56 --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/errors/for_loop_inferred_type.out @@ -0,0 +1,10 @@ +GDTEST_ANALYZER_ERROR +>> ERROR at line 14: Unable to iterate on value of type "bool". +>> ERROR at line 18: Expression is of type "int" so it can't be of type "String". +>> ERROR at line 25: Expression is of type "int" so it can't be of type "String". +>> ERROR at line 30: Expression is of type "float" so it can't be of type "String". +>> ERROR at line 37: Expression is of type "int" so it can't be of type "String". +>> ERROR at line 42: Expression is of type "float" so it can't be of type "String". +>> ERROR at line 47: Expression is of type "String" so it can't be of type "int". +>> ERROR at line 53: Expression is of type "int" so it can't be of type "String". +>> ERROR at line 58: Expression is of type "StringName" so it can't be of type "int". diff --git a/modules/gdscript/tests/scripts/analyzer/errors/for_loop_on_constant_float.gd b/modules/gdscript/tests/scripts/analyzer/errors/for_loop_on_constant_float.gd deleted file mode 100644 index cf56a0a9335..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/for_loop_on_constant_float.gd +++ /dev/null @@ -1,6 +0,0 @@ -const constant_float = 1.0 - -func test(): - for x in constant_float: - if x is String: - pass diff --git a/modules/gdscript/tests/scripts/analyzer/errors/for_loop_on_constant_float.out b/modules/gdscript/tests/scripts/analyzer/errors/for_loop_on_constant_float.out deleted file mode 100644 index 28f0886fd5e..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/for_loop_on_constant_float.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 5: Expression is of type "float" so it can't be of type "String". diff --git a/modules/gdscript/tests/scripts/analyzer/errors/for_loop_on_constant_int.gd b/modules/gdscript/tests/scripts/analyzer/errors/for_loop_on_constant_int.gd deleted file mode 100644 index 5ee8ac19e11..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/for_loop_on_constant_int.gd +++ /dev/null @@ -1,6 +0,0 @@ -const constant_int = 1 - -func test(): - for x in constant_int: - if x is String: - pass diff --git a/modules/gdscript/tests/scripts/analyzer/errors/for_loop_on_constant_int.out b/modules/gdscript/tests/scripts/analyzer/errors/for_loop_on_constant_int.out deleted file mode 100644 index c42bb0f974a..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/for_loop_on_constant_int.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 5: Expression is of type "int" so it can't be of type "String". diff --git a/modules/gdscript/tests/scripts/analyzer/errors/for_loop_on_enum_value.gd b/modules/gdscript/tests/scripts/analyzer/errors/for_loop_on_enum_value.gd deleted file mode 100644 index b3db4f3b498..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/for_loop_on_enum_value.gd +++ /dev/null @@ -1,6 +0,0 @@ -enum { enum_value = 1 } - -func test(): - for x in enum_value: - if x is String: - pass diff --git a/modules/gdscript/tests/scripts/analyzer/errors/for_loop_on_enum_value.out b/modules/gdscript/tests/scripts/analyzer/errors/for_loop_on_enum_value.out deleted file mode 100644 index c42bb0f974a..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/for_loop_on_enum_value.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 5: Expression is of type "int" so it can't be of type "String". diff --git a/modules/gdscript/tests/scripts/analyzer/errors/for_loop_on_hard_float.gd b/modules/gdscript/tests/scripts/analyzer/errors/for_loop_on_hard_float.gd deleted file mode 100644 index 87c54f7402a..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/for_loop_on_hard_float.gd +++ /dev/null @@ -1,6 +0,0 @@ -func test(): - var hard_float := 1.0 - - for x in hard_float: - if x is String: - pass diff --git a/modules/gdscript/tests/scripts/analyzer/errors/for_loop_on_hard_float.out b/modules/gdscript/tests/scripts/analyzer/errors/for_loop_on_hard_float.out deleted file mode 100644 index 28f0886fd5e..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/for_loop_on_hard_float.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 5: Expression is of type "float" so it can't be of type "String". diff --git a/modules/gdscript/tests/scripts/analyzer/errors/for_loop_on_hard_int.gd b/modules/gdscript/tests/scripts/analyzer/errors/for_loop_on_hard_int.gd deleted file mode 100644 index 2a43f5a930c..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/for_loop_on_hard_int.gd +++ /dev/null @@ -1,6 +0,0 @@ -func test(): - var hard_int := 1 - - for x in hard_int: - if x is String: - pass diff --git a/modules/gdscript/tests/scripts/analyzer/errors/for_loop_on_hard_int.out b/modules/gdscript/tests/scripts/analyzer/errors/for_loop_on_hard_int.out deleted file mode 100644 index c42bb0f974a..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/for_loop_on_hard_int.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 5: Expression is of type "int" so it can't be of type "String". diff --git a/modules/gdscript/tests/scripts/analyzer/errors/for_loop_on_hard_iterator.gd b/modules/gdscript/tests/scripts/analyzer/errors/for_loop_on_hard_iterator.gd deleted file mode 100644 index c3920d35b38..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/for_loop_on_hard_iterator.gd +++ /dev/null @@ -1,14 +0,0 @@ -class Iterator: - func _iter_init(_count): - return true - func _iter_next(_count): - return false - func _iter_get(_count) -> StringName: - return &'custom' - -func test(): - var hard_iterator := Iterator.new() - - for x in hard_iterator: - if x is int: - pass diff --git a/modules/gdscript/tests/scripts/analyzer/errors/for_loop_on_hard_iterator.out b/modules/gdscript/tests/scripts/analyzer/errors/for_loop_on_hard_iterator.out deleted file mode 100644 index 91aefc3f2ce..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/for_loop_on_hard_iterator.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 13: Expression is of type "StringName" so it can't be of type "int". diff --git a/modules/gdscript/tests/scripts/analyzer/errors/for_loop_on_hard_string.gd b/modules/gdscript/tests/scripts/analyzer/errors/for_loop_on_hard_string.gd deleted file mode 100644 index b36d87aabe8..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/for_loop_on_hard_string.gd +++ /dev/null @@ -1,6 +0,0 @@ -func test(): - var hard_string := 'a' - - for x in hard_string: - if x is int: - pass diff --git a/modules/gdscript/tests/scripts/analyzer/errors/for_loop_on_hard_string.out b/modules/gdscript/tests/scripts/analyzer/errors/for_loop_on_hard_string.out deleted file mode 100644 index 1e9d9e4ec80..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/for_loop_on_hard_string.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 5: Expression is of type "String" so it can't be of type "int". diff --git a/modules/gdscript/tests/scripts/analyzer/errors/for_loop_on_literal_bool.gd b/modules/gdscript/tests/scripts/analyzer/errors/for_loop_on_literal_bool.gd deleted file mode 100644 index 060a8bedf9c..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/for_loop_on_literal_bool.gd +++ /dev/null @@ -1,3 +0,0 @@ -func test(): - for x in true: - pass diff --git a/modules/gdscript/tests/scripts/analyzer/errors/for_loop_on_literal_bool.out b/modules/gdscript/tests/scripts/analyzer/errors/for_loop_on_literal_bool.out deleted file mode 100644 index a9e118ca3d6..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/for_loop_on_literal_bool.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 2: Unable to iterate on value of type "bool". diff --git a/modules/gdscript/tests/scripts/analyzer/errors/for_loop_on_literal_int.gd b/modules/gdscript/tests/scripts/analyzer/errors/for_loop_on_literal_int.gd deleted file mode 100644 index 6cfc822482c..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/for_loop_on_literal_int.gd +++ /dev/null @@ -1,4 +0,0 @@ -func test(): - for x in 1: - if x is String: - pass diff --git a/modules/gdscript/tests/scripts/analyzer/errors/for_loop_on_literal_int.out b/modules/gdscript/tests/scripts/analyzer/errors/for_loop_on_literal_int.out deleted file mode 100644 index d812e7a5b6a..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/for_loop_on_literal_int.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 3: Expression is of type "int" so it can't be of type "String". diff --git a/modules/gdscript/tests/scripts/analyzer/errors/for_loop_wrong_specified_type.gd b/modules/gdscript/tests/scripts/analyzer/errors/for_loop_wrong_specified_type.gd index 7e3b6e3c398..4a0440c6f0f 100644 --- a/modules/gdscript/tests/scripts/analyzer/errors/for_loop_wrong_specified_type.gd +++ b/modules/gdscript/tests/scripts/analyzer/errors/for_loop_wrong_specified_type.gd @@ -2,3 +2,10 @@ func test(): var a: Array[Resource] = [] for node: Node in a: print(node) + + # GH-82021 + for x: String in [1, 2, 3]: + print(x) + + for key: int in { "a": 1 }: + print(key) diff --git a/modules/gdscript/tests/scripts/analyzer/errors/for_loop_wrong_specified_type.out b/modules/gdscript/tests/scripts/analyzer/errors/for_loop_wrong_specified_type.out index f84bcf7873a..6b7e235755f 100644 --- a/modules/gdscript/tests/scripts/analyzer/errors/for_loop_wrong_specified_type.out +++ b/modules/gdscript/tests/scripts/analyzer/errors/for_loop_wrong_specified_type.out @@ -1,2 +1,6 @@ GDTEST_ANALYZER_ERROR >> ERROR at line 3: Unable to iterate on value of type "Array[Resource]" with variable of type "Node". +>> ERROR at line 7: Cannot include a value of type "int" as "String". +>> ERROR at line 7: Cannot have an element of type "int" in an array of type "Array[String]". +>> ERROR at line 10: Cannot include a value of type "String" as "int". +>> ERROR at line 10: Cannot have a key of type "String" in a dictionary of type "Dictionary[int, Variant]". diff --git a/modules/gdscript/tests/scripts/analyzer/errors/for_loop_wrong_specified_type_with_literal_array.gd b/modules/gdscript/tests/scripts/analyzer/errors/for_loop_wrong_specified_type_with_literal_array.gd deleted file mode 100644 index db3f3f4c727..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/for_loop_wrong_specified_type_with_literal_array.gd +++ /dev/null @@ -1,5 +0,0 @@ -# GH-82021 - -func test(): - for x: String in [1, 2, 3]: - print(x) diff --git a/modules/gdscript/tests/scripts/analyzer/errors/for_loop_wrong_specified_type_with_literal_array.out b/modules/gdscript/tests/scripts/analyzer/errors/for_loop_wrong_specified_type_with_literal_array.out deleted file mode 100644 index 8d7c515d629..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/for_loop_wrong_specified_type_with_literal_array.out +++ /dev/null @@ -1,3 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 4: Cannot include a value of type "int" as "String". ->> ERROR at line 4: Cannot have an element of type "int" in an array of type "Array[String]". diff --git a/modules/gdscript/tests/scripts/analyzer/errors/for_loop_wrong_specified_type_with_literal_dictionary.gd b/modules/gdscript/tests/scripts/analyzer/errors/for_loop_wrong_specified_type_with_literal_dictionary.gd deleted file mode 100644 index c180cca03cc..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/for_loop_wrong_specified_type_with_literal_dictionary.gd +++ /dev/null @@ -1,3 +0,0 @@ -func test(): - for key: int in { "a": 1 }: - print(key) diff --git a/modules/gdscript/tests/scripts/analyzer/errors/for_loop_wrong_specified_type_with_literal_dictionary.out b/modules/gdscript/tests/scripts/analyzer/errors/for_loop_wrong_specified_type_with_literal_dictionary.out deleted file mode 100644 index 6ec5c275e45..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/for_loop_wrong_specified_type_with_literal_dictionary.out +++ /dev/null @@ -1,3 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 2: Cannot include a value of type "String" as "int". ->> ERROR at line 2: Cannot have a key of type "String" in a dictionary of type "Dictionary[int, Variant]". diff --git a/modules/gdscript/tests/scripts/analyzer/errors/function_dont_match_parent_signature_parameter_count_less.gd b/modules/gdscript/tests/scripts/analyzer/errors/function_dont_match_parent_signature_parameter_count_less.gd deleted file mode 100644 index 435711fcafc..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/function_dont_match_parent_signature_parameter_count_less.gd +++ /dev/null @@ -1,10 +0,0 @@ -func test(): - print("Shouldn't reach this") - -class Parent: - func my_function(_par1: int) -> int: - return 0 - -class Child extends Parent: - func my_function() -> int: - return 0 diff --git a/modules/gdscript/tests/scripts/analyzer/errors/function_dont_match_parent_signature_parameter_count_less.out b/modules/gdscript/tests/scripts/analyzer/errors/function_dont_match_parent_signature_parameter_count_less.out deleted file mode 100644 index 4b706eb8277..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/function_dont_match_parent_signature_parameter_count_less.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 9: The function signature doesn't match the parent. Parent signature is "my_function(int) -> int". diff --git a/modules/gdscript/tests/scripts/analyzer/errors/function_dont_match_parent_signature_parameter_count_more.gd b/modules/gdscript/tests/scripts/analyzer/errors/function_dont_match_parent_signature_parameter_count_more.gd deleted file mode 100644 index 2bd392e8f8a..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/function_dont_match_parent_signature_parameter_count_more.gd +++ /dev/null @@ -1,10 +0,0 @@ -func test(): - print("Shouldn't reach this") - -class Parent: - func my_function(_par1: int) -> int: - return 0 - -class Child extends Parent: - func my_function(_pary1: int, _par2: int) -> int: - return 0 diff --git a/modules/gdscript/tests/scripts/analyzer/errors/function_dont_match_parent_signature_parameter_count_more.out b/modules/gdscript/tests/scripts/analyzer/errors/function_dont_match_parent_signature_parameter_count_more.out deleted file mode 100644 index 4b706eb8277..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/function_dont_match_parent_signature_parameter_count_more.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 9: The function signature doesn't match the parent. Parent signature is "my_function(int) -> int". diff --git a/modules/gdscript/tests/scripts/analyzer/errors/function_dont_match_parent_signature_parameter_default_values.gd b/modules/gdscript/tests/scripts/analyzer/errors/function_dont_match_parent_signature_parameter_default_values.gd deleted file mode 100644 index 49ec82ce2de..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/function_dont_match_parent_signature_parameter_default_values.gd +++ /dev/null @@ -1,10 +0,0 @@ -func test(): - print("Shouldn't reach this") - -class Parent: - func my_function(_par1: int = 0) -> int: - return 0 - -class Child extends Parent: - func my_function(_par1: int) -> int: - return 0 diff --git a/modules/gdscript/tests/scripts/analyzer/errors/function_dont_match_parent_signature_parameter_default_values.out b/modules/gdscript/tests/scripts/analyzer/errors/function_dont_match_parent_signature_parameter_default_values.out deleted file mode 100644 index 27c77fa04ee..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/function_dont_match_parent_signature_parameter_default_values.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 9: The function signature doesn't match the parent. Parent signature is "my_function(int = ) -> int". diff --git a/modules/gdscript/tests/scripts/analyzer/errors/function_dont_match_parent_signature_parameter_type.gd b/modules/gdscript/tests/scripts/analyzer/errors/function_dont_match_parent_signature_parameter_type.gd deleted file mode 100644 index 4a17a7831f0..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/function_dont_match_parent_signature_parameter_type.gd +++ /dev/null @@ -1,10 +0,0 @@ -func test(): - print("Shouldn't reach this") - -class Parent: - func my_function(_par1: int) -> int: - return 0 - -class Child extends Parent: - func my_function(_par1: Vector2) -> int: - return 0 diff --git a/modules/gdscript/tests/scripts/analyzer/errors/function_dont_match_parent_signature_parameter_type.out b/modules/gdscript/tests/scripts/analyzer/errors/function_dont_match_parent_signature_parameter_type.out deleted file mode 100644 index 4b706eb8277..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/function_dont_match_parent_signature_parameter_type.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 9: The function signature doesn't match the parent. Parent signature is "my_function(int) -> int". diff --git a/modules/gdscript/tests/scripts/analyzer/errors/function_dont_match_parent_signature_return_type.gd b/modules/gdscript/tests/scripts/analyzer/errors/function_dont_match_parent_signature_return_type.gd deleted file mode 100644 index b205ec96ef2..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/function_dont_match_parent_signature_return_type.gd +++ /dev/null @@ -1,10 +0,0 @@ -func test(): - print("Shouldn't reach this") - -class Parent: - func my_function() -> int: - return 0 - -class Child extends Parent: - func my_function() -> Vector2: - return Vector2() diff --git a/modules/gdscript/tests/scripts/analyzer/errors/function_dont_match_parent_signature_return_type.out b/modules/gdscript/tests/scripts/analyzer/errors/function_dont_match_parent_signature_return_type.out deleted file mode 100644 index 3393b17dab8..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/function_dont_match_parent_signature_return_type.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 9: The function signature doesn't match the parent. Parent signature is "my_function() -> int". diff --git a/modules/gdscript/tests/scripts/analyzer/errors/function_param_type_invalid_contravariance_1.gd b/modules/gdscript/tests/scripts/analyzer/errors/function_param_type_invalid_contravariance_1.gd deleted file mode 100644 index fdf22f6843a..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/function_param_type_invalid_contravariance_1.gd +++ /dev/null @@ -1,10 +0,0 @@ -class A: - func f(_p: Object): - pass - -class B extends A: - func f(_p: Node): - pass - -func test(): - pass diff --git a/modules/gdscript/tests/scripts/analyzer/errors/function_param_type_invalid_contravariance_1.out b/modules/gdscript/tests/scripts/analyzer/errors/function_param_type_invalid_contravariance_1.out deleted file mode 100644 index ff37d4298e5..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/function_param_type_invalid_contravariance_1.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 6: The function signature doesn't match the parent. Parent signature is "f(Object) -> Variant". diff --git a/modules/gdscript/tests/scripts/analyzer/errors/function_param_type_invalid_contravariance_2.gd b/modules/gdscript/tests/scripts/analyzer/errors/function_param_type_invalid_contravariance_2.gd deleted file mode 100644 index e4094f1d761..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/function_param_type_invalid_contravariance_2.gd +++ /dev/null @@ -1,10 +0,0 @@ -class A: - func f(_p: Variant): - pass - -class B extends A: - func f(_p: Node): # No `is_type_compatible()` misuse. - pass - -func test(): - pass diff --git a/modules/gdscript/tests/scripts/analyzer/errors/function_param_type_invalid_contravariance_2.out b/modules/gdscript/tests/scripts/analyzer/errors/function_param_type_invalid_contravariance_2.out deleted file mode 100644 index 0e9f07e18ac..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/function_param_type_invalid_contravariance_2.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 6: The function signature doesn't match the parent. Parent signature is "f(Variant) -> Variant". diff --git a/modules/gdscript/tests/scripts/analyzer/errors/function_param_type_invalid_contravariance_3.gd b/modules/gdscript/tests/scripts/analyzer/errors/function_param_type_invalid_contravariance_3.gd deleted file mode 100644 index 17663da4f60..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/function_param_type_invalid_contravariance_3.gd +++ /dev/null @@ -1,10 +0,0 @@ -class A: - func f(_p: int): - pass - -class B extends A: - func f(_p: float): # No implicit conversion. - pass - -func test(): - pass diff --git a/modules/gdscript/tests/scripts/analyzer/errors/function_param_type_invalid_contravariance_3.out b/modules/gdscript/tests/scripts/analyzer/errors/function_param_type_invalid_contravariance_3.out deleted file mode 100644 index f2461c50026..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/function_param_type_invalid_contravariance_3.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 6: The function signature doesn't match the parent. Parent signature is "f(int) -> Variant". diff --git a/modules/gdscript/tests/scripts/analyzer/errors/function_return_type_invalid_covariance_1.gd b/modules/gdscript/tests/scripts/analyzer/errors/function_return_type_invalid_covariance_1.gd deleted file mode 100644 index 6dfa75ecbc2..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/function_return_type_invalid_covariance_1.gd +++ /dev/null @@ -1,10 +0,0 @@ -class A: - func f() -> Node: - return null - -class B extends A: - func f() -> Object: - return null - -func test(): - pass diff --git a/modules/gdscript/tests/scripts/analyzer/errors/function_return_type_invalid_covariance_1.out b/modules/gdscript/tests/scripts/analyzer/errors/function_return_type_invalid_covariance_1.out deleted file mode 100644 index fc326592d6a..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/function_return_type_invalid_covariance_1.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 6: The function signature doesn't match the parent. Parent signature is "f() -> Node". diff --git a/modules/gdscript/tests/scripts/analyzer/errors/function_return_type_invalid_covariance_2.gd b/modules/gdscript/tests/scripts/analyzer/errors/function_return_type_invalid_covariance_2.gd deleted file mode 100644 index 366494b94fb..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/function_return_type_invalid_covariance_2.gd +++ /dev/null @@ -1,10 +0,0 @@ -class A: - func f() -> Node: - return null - -class B extends A: - func f() -> Variant: # No `is_type_compatible()` misuse. - return null - -func test(): - pass diff --git a/modules/gdscript/tests/scripts/analyzer/errors/function_return_type_invalid_covariance_2.out b/modules/gdscript/tests/scripts/analyzer/errors/function_return_type_invalid_covariance_2.out deleted file mode 100644 index fc326592d6a..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/function_return_type_invalid_covariance_2.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 6: The function signature doesn't match the parent. Parent signature is "f() -> Node". diff --git a/modules/gdscript/tests/scripts/analyzer/errors/function_return_type_invalid_covariance_3.gd b/modules/gdscript/tests/scripts/analyzer/errors/function_return_type_invalid_covariance_3.gd deleted file mode 100644 index 2cb4e7c6161..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/function_return_type_invalid_covariance_3.gd +++ /dev/null @@ -1,10 +0,0 @@ -class A: - func f() -> Node: - return null - -class B extends A: - func f() -> void: # No `is_type_compatible()` misuse. - return - -func test(): - pass diff --git a/modules/gdscript/tests/scripts/analyzer/errors/function_return_type_invalid_covariance_3.out b/modules/gdscript/tests/scripts/analyzer/errors/function_return_type_invalid_covariance_3.out deleted file mode 100644 index fc326592d6a..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/function_return_type_invalid_covariance_3.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 6: The function signature doesn't match the parent. Parent signature is "f() -> Node". diff --git a/modules/gdscript/tests/scripts/analyzer/errors/function_return_type_invalid_covariance_4.gd b/modules/gdscript/tests/scripts/analyzer/errors/function_return_type_invalid_covariance_4.gd deleted file mode 100644 index 2cabce46f5e..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/function_return_type_invalid_covariance_4.gd +++ /dev/null @@ -1,10 +0,0 @@ -class A: - func f() -> float: - return 0.0 - -class B extends A: - func f() -> int: # No implicit conversion. - return 0 - -func test(): - pass diff --git a/modules/gdscript/tests/scripts/analyzer/errors/function_return_type_invalid_covariance_4.out b/modules/gdscript/tests/scripts/analyzer/errors/function_return_type_invalid_covariance_4.out deleted file mode 100644 index ef983348adb..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/function_return_type_invalid_covariance_4.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 6: The function signature doesn't match the parent. Parent signature is "f() -> float". diff --git a/modules/gdscript/tests/scripts/analyzer/errors/function_signature_compatibility.gd b/modules/gdscript/tests/scripts/analyzer/errors/function_signature_compatibility.gd new file mode 100644 index 00000000000..22f79a8e0b7 --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/errors/function_signature_compatibility.gd @@ -0,0 +1,34 @@ +class A: + func f1(_p1: int) -> int: return 0 + func f2(_p1: int) -> int: return 0 + func f3(_p1: int = 0) -> int: return 0 + func f4(_p1: int) -> int: return 0 + func f5() -> int: return 0 + + func g1(_p: Object): pass + func g2(_p: Variant): pass # No `is_type_compatible()` misuse. + func g3(_p: int): pass # No implicit conversion. + + func h1() -> Node: return null + func h2() -> Node: return null # No `is_type_compatible()` misuse. + func h3() -> Node: return null # No `is_type_compatible()` misuse. + func h4() -> float: return 0.0 # No implicit conversion. + +class B extends A: + func f1() -> int: return 0 + func f2(_p1: int, _p2: int) -> int: return 0 + func f3(_p1: int) -> int: return 0 + func f4(_p1: Vector2) -> int: return 0 + func f5() -> Vector2: return Vector2() + + func g1(_p: Node): pass + func g2(_p: Node): pass + func g3(_p: float): pass + + func h1() -> Object: return null + func h2() -> Variant: return null + func h3() -> void: return + func h4() -> int: return 0 + +func test(): + pass diff --git a/modules/gdscript/tests/scripts/analyzer/errors/function_signature_compatibility.out b/modules/gdscript/tests/scripts/analyzer/errors/function_signature_compatibility.out new file mode 100644 index 00000000000..a17c0f6334e --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/errors/function_signature_compatibility.out @@ -0,0 +1,13 @@ +GDTEST_ANALYZER_ERROR +>> ERROR at line 18: The function signature doesn't match the parent. Parent signature is "f1(int) -> int". +>> ERROR at line 19: The function signature doesn't match the parent. Parent signature is "f2(int) -> int". +>> ERROR at line 20: The function signature doesn't match the parent. Parent signature is "f3(int = ) -> int". +>> ERROR at line 21: The function signature doesn't match the parent. Parent signature is "f4(int) -> int". +>> ERROR at line 22: The function signature doesn't match the parent. Parent signature is "f5() -> int". +>> ERROR at line 24: The function signature doesn't match the parent. Parent signature is "g1(Object) -> Variant". +>> ERROR at line 25: The function signature doesn't match the parent. Parent signature is "g2(Variant) -> Variant". +>> ERROR at line 26: The function signature doesn't match the parent. Parent signature is "g3(int) -> Variant". +>> ERROR at line 28: The function signature doesn't match the parent. Parent signature is "h1() -> Node". +>> ERROR at line 29: The function signature doesn't match the parent. Parent signature is "h2() -> Node". +>> ERROR at line 30: The function signature doesn't match the parent. Parent signature is "h3() -> Node". +>> ERROR at line 31: The function signature doesn't match the parent. Parent signature is "h4() -> float". diff --git a/modules/gdscript/tests/scripts/analyzer/errors/function_used_as_property.gd b/modules/gdscript/tests/scripts/analyzer/errors/function_used_as_property.gd deleted file mode 100644 index 4346503fc29..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/function_used_as_property.gd +++ /dev/null @@ -1,6 +0,0 @@ -func function(): - pass - - -func test(): - function = 25 diff --git a/modules/gdscript/tests/scripts/analyzer/errors/gd_utility_function_wrong_arg.gd b/modules/gdscript/tests/scripts/analyzer/errors/gd_utility_function_wrong_arg.gd deleted file mode 100644 index c06fbd89ff2..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/gd_utility_function_wrong_arg.gd +++ /dev/null @@ -1,2 +0,0 @@ -func test(): - print(len(Color())) # GDScript utility function. diff --git a/modules/gdscript/tests/scripts/analyzer/errors/gd_utility_function_wrong_arg.out b/modules/gdscript/tests/scripts/analyzer/errors/gd_utility_function_wrong_arg.out deleted file mode 100644 index 300a14ab740..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/gd_utility_function_wrong_arg.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 2: Invalid argument for "len()" function: Value of type 'Color' can't provide a length. diff --git a/modules/gdscript/tests/scripts/analyzer/errors/get_node_shorthand.gd b/modules/gdscript/tests/scripts/analyzer/errors/get_node_shorthand.gd new file mode 100644 index 00000000000..9610d3cd81b --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/errors/get_node_shorthand.gd @@ -0,0 +1,11 @@ +# GH-75645 +class MyNode extends Node: + static func static_func(): + var node = $Node + +class MyRefCounted extends RefCounted: + func non_static_func(): + var node = $Node + +func test(): + pass diff --git a/modules/gdscript/tests/scripts/analyzer/errors/get_node_shorthand_within_non_node.out b/modules/gdscript/tests/scripts/analyzer/errors/get_node_shorthand.out similarity index 53% rename from modules/gdscript/tests/scripts/analyzer/errors/get_node_shorthand_within_non_node.out rename to modules/gdscript/tests/scripts/analyzer/errors/get_node_shorthand.out index 5f1a5c2ec80..3f375e76709 100644 --- a/modules/gdscript/tests/scripts/analyzer/errors/get_node_shorthand_within_non_node.out +++ b/modules/gdscript/tests/scripts/analyzer/errors/get_node_shorthand.out @@ -1,3 +1,3 @@ GDTEST_ANALYZER_ERROR ->> ERROR at line 4: Cannot use shorthand "get_node()" notation ("$") on a class that isn't a node. ->> ERROR at line 4: Cannot infer the type of "nope" variable because the value doesn't have a set type. +>> ERROR at line 4: Cannot use shorthand "get_node()" notation ("$") in a static function. +>> ERROR at line 8: Cannot use shorthand "get_node()" notation ("$") on a class that isn't a node. diff --git a/modules/gdscript/tests/scripts/analyzer/errors/get_node_shorthand_in_static_function.gd b/modules/gdscript/tests/scripts/analyzer/errors/get_node_shorthand_in_static_function.gd deleted file mode 100644 index caeea46977f..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/get_node_shorthand_in_static_function.gd +++ /dev/null @@ -1,9 +0,0 @@ -# GH-75645 - -extends Node - -static func static_func(): - var a = $Node - -func test(): - pass diff --git a/modules/gdscript/tests/scripts/analyzer/errors/get_node_shorthand_in_static_function.out b/modules/gdscript/tests/scripts/analyzer/errors/get_node_shorthand_in_static_function.out deleted file mode 100644 index 4b8f3b31510..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/get_node_shorthand_in_static_function.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 6: Cannot use shorthand "get_node()" notation ("$") in a static function. diff --git a/modules/gdscript/tests/scripts/analyzer/errors/get_node_shorthand_within_non_node.gd b/modules/gdscript/tests/scripts/analyzer/errors/get_node_shorthand_within_non_node.gd deleted file mode 100644 index 91f5071fa95..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/get_node_shorthand_within_non_node.gd +++ /dev/null @@ -1,5 +0,0 @@ -extends RefCounted - -func test(): - var nope := $Node - print("Cannot use $ without a Node base") diff --git a/modules/gdscript/tests/scripts/analyzer/errors/inferring_with_weak_type.gd b/modules/gdscript/tests/scripts/analyzer/errors/inferring_with_weak_type.gd new file mode 100644 index 00000000000..65e20088e45 --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/errors/inferring_with_weak_type.gd @@ -0,0 +1,9 @@ +var member_untyped = 1 +var member_inferred := member_untyped + +func check(param_untyped = 1, param_inferred := param_untyped): + pass + +func test(): + var local_untyped = 1 + var local_inferred := local_untyped diff --git a/modules/gdscript/tests/scripts/analyzer/errors/inferring_with_weak_type.out b/modules/gdscript/tests/scripts/analyzer/errors/inferring_with_weak_type.out new file mode 100644 index 00000000000..dbca717db25 --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/errors/inferring_with_weak_type.out @@ -0,0 +1,4 @@ +GDTEST_ANALYZER_ERROR +>> ERROR at line 2: Cannot infer the type of "member_inferred" variable because the value doesn't have a set type. +>> ERROR at line 4: Cannot infer the type of "param_inferred" parameter because the value doesn't have a set type. +>> ERROR at line 9: Cannot infer the type of "local_inferred" variable because the value doesn't have a set type. diff --git a/modules/gdscript/tests/scripts/analyzer/errors/inferring_with_weak_type_local_variable.gd b/modules/gdscript/tests/scripts/analyzer/errors/inferring_with_weak_type_local_variable.gd deleted file mode 100644 index 6014ee831c1..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/inferring_with_weak_type_local_variable.gd +++ /dev/null @@ -1,3 +0,0 @@ -func test(): - var untyped = 1 - var inferred := untyped diff --git a/modules/gdscript/tests/scripts/analyzer/errors/inferring_with_weak_type_local_variable.out b/modules/gdscript/tests/scripts/analyzer/errors/inferring_with_weak_type_local_variable.out deleted file mode 100644 index d6d818891b4..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/inferring_with_weak_type_local_variable.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 3: Cannot infer the type of "inferred" variable because the value doesn't have a set type. diff --git a/modules/gdscript/tests/scripts/analyzer/errors/inferring_with_weak_type_member_variable.gd b/modules/gdscript/tests/scripts/analyzer/errors/inferring_with_weak_type_member_variable.gd deleted file mode 100644 index 040aa2e82a8..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/inferring_with_weak_type_member_variable.gd +++ /dev/null @@ -1,5 +0,0 @@ -var untyped = 1 -var inferred := untyped - -func test(): - pass diff --git a/modules/gdscript/tests/scripts/analyzer/errors/inferring_with_weak_type_member_variable.out b/modules/gdscript/tests/scripts/analyzer/errors/inferring_with_weak_type_member_variable.out deleted file mode 100644 index aa4c98a4ba6..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/inferring_with_weak_type_member_variable.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 2: Cannot infer the type of "inferred" variable because the value doesn't have a set type. diff --git a/modules/gdscript/tests/scripts/analyzer/errors/inferring_with_weak_type_parameter.gd b/modules/gdscript/tests/scripts/analyzer/errors/inferring_with_weak_type_parameter.gd deleted file mode 100644 index 80c676488e4..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/inferring_with_weak_type_parameter.gd +++ /dev/null @@ -1,5 +0,0 @@ -func check(untyped = 1, inferred := untyped): - pass - -func test(): - check() diff --git a/modules/gdscript/tests/scripts/analyzer/errors/inferring_with_weak_type_parameter.out b/modules/gdscript/tests/scripts/analyzer/errors/inferring_with_weak_type_parameter.out deleted file mode 100644 index dca793b5a09..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/inferring_with_weak_type_parameter.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 1: Cannot infer the type of "inferred" parameter because the value doesn't have a set type. diff --git a/modules/gdscript/tests/scripts/analyzer/errors/cast_object_to_int.gd b/modules/gdscript/tests/scripts/analyzer/errors/invalid_cast.gd similarity index 50% rename from modules/gdscript/tests/scripts/analyzer/errors/cast_object_to_int.gd rename to modules/gdscript/tests/scripts/analyzer/errors/invalid_cast.gd index f6cd5e217e4..a91373a0e7d 100644 --- a/modules/gdscript/tests/scripts/analyzer/errors/cast_object_to_int.gd +++ b/modules/gdscript/tests/scripts/analyzer/errors/invalid_cast.gd @@ -1,3 +1,6 @@ func test(): + var integer := 1 + print(integer as Array) + print(integer as Node) var object := RefCounted.new() print(object as int) diff --git a/modules/gdscript/tests/scripts/analyzer/errors/invalid_cast.out b/modules/gdscript/tests/scripts/analyzer/errors/invalid_cast.out new file mode 100644 index 00000000000..39c09d16e00 --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/errors/invalid_cast.out @@ -0,0 +1,4 @@ +GDTEST_ANALYZER_ERROR +>> ERROR at line 3: Invalid cast. Cannot convert from "int" to "Array". +>> ERROR at line 4: Invalid cast. Cannot convert from "int" to "Node". +>> ERROR at line 6: Invalid cast. Cannot convert from "RefCounted" to "int". diff --git a/modules/gdscript/tests/scripts/analyzer/errors/invalid_concatenation_dictionary.gd b/modules/gdscript/tests/scripts/analyzer/errors/invalid_concatenation.gd similarity index 56% rename from modules/gdscript/tests/scripts/analyzer/errors/invalid_concatenation_dictionary.gd rename to modules/gdscript/tests/scripts/analyzer/errors/invalid_concatenation.gd index 6aec2e07967..ce87cdfb2c4 100644 --- a/modules/gdscript/tests/scripts/analyzer/errors/invalid_concatenation_dictionary.gd +++ b/modules/gdscript/tests/scripts/analyzer/errors/invalid_concatenation.gd @@ -1,2 +1,4 @@ func test(): + print(true + true) print({"hello": "world"} + {"godot": "engine"}) + print("hello" + ["world"]) diff --git a/modules/gdscript/tests/scripts/analyzer/errors/invalid_concatenation.out b/modules/gdscript/tests/scripts/analyzer/errors/invalid_concatenation.out new file mode 100644 index 00000000000..5f6d951296b --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/errors/invalid_concatenation.out @@ -0,0 +1,4 @@ +GDTEST_ANALYZER_ERROR +>> ERROR at line 2: Invalid operands to operator +, bool and bool. +>> ERROR at line 3: Invalid operands "Dictionary" and "Dictionary" for "+" operator. +>> ERROR at line 4: Invalid operands "String" and "Array" for "+" operator. diff --git a/modules/gdscript/tests/scripts/analyzer/errors/invalid_concatenation_bool.gd b/modules/gdscript/tests/scripts/analyzer/errors/invalid_concatenation_bool.gd deleted file mode 100644 index c159e031408..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/invalid_concatenation_bool.gd +++ /dev/null @@ -1,2 +0,0 @@ -func test(): - print(true + true) diff --git a/modules/gdscript/tests/scripts/analyzer/errors/invalid_concatenation_bool.out b/modules/gdscript/tests/scripts/analyzer/errors/invalid_concatenation_bool.out deleted file mode 100644 index e2ff31efbea..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/invalid_concatenation_bool.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 2: Invalid operands to operator +, bool and bool. diff --git a/modules/gdscript/tests/scripts/analyzer/errors/invalid_concatenation_dictionary.out b/modules/gdscript/tests/scripts/analyzer/errors/invalid_concatenation_dictionary.out deleted file mode 100644 index a120670f382..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/invalid_concatenation_dictionary.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 2: Invalid operands "Dictionary" and "Dictionary" for "+" operator. diff --git a/modules/gdscript/tests/scripts/analyzer/errors/invalid_concatenation_mixed.gd b/modules/gdscript/tests/scripts/analyzer/errors/invalid_concatenation_mixed.gd deleted file mode 100644 index eb2a6a0ce7c..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/invalid_concatenation_mixed.gd +++ /dev/null @@ -1,2 +0,0 @@ -func test(): - print("hello" + ["world"]) diff --git a/modules/gdscript/tests/scripts/analyzer/errors/invalid_concatenation_mixed.out b/modules/gdscript/tests/scripts/analyzer/errors/invalid_concatenation_mixed.out deleted file mode 100644 index bce8b7d1051..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/invalid_concatenation_mixed.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 2: Invalid operands "String" and "Array" for "+" operator. diff --git a/modules/gdscript/tests/scripts/analyzer/errors/invalid_inheritance.gd b/modules/gdscript/tests/scripts/analyzer/errors/invalid_inheritance.gd new file mode 100644 index 00000000000..7d9eaa5abca --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/errors/invalid_inheritance.gd @@ -0,0 +1,35 @@ +class SomeClass: + const CONSTANT = 1 + +const CONSTANT = 1 + +var variable = 1 + +# GH-75870 + +class Class1 extends CONSTANT: + pass + +class Class2 extends variable: + pass + +# GH-82081. `Time` is an engine singleton. +class Class3 extends Time: + pass + +class Class4 extends RefCounted.Nested: + pass + +class Class5 extends SomeClass.UnknownClass: + pass + +class Class6 extends SomeClass.CONSTANT: + pass + +class ClassA extends ClassB: + pass +class ClassB extends ClassA: + pass + +func test(): + pass diff --git a/modules/gdscript/tests/scripts/analyzer/errors/invalid_inheritance.out b/modules/gdscript/tests/scripts/analyzer/errors/invalid_inheritance.out new file mode 100644 index 00000000000..d0d2ea7594e --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/errors/invalid_inheritance.out @@ -0,0 +1,8 @@ +GDTEST_ANALYZER_ERROR +>> ERROR at line 10: Constant "CONSTANT" is not a preloaded script or class. +>> ERROR at line 13: Cannot use variable "variable" in extends chain. +>> ERROR at line 17: Cannot inherit native class "Time" because it is an engine singleton. +>> ERROR at line 20: Cannot get nested types for extension from non-GDScript type "RefCounted". +>> ERROR at line 23: Could not find nested type "UnknownClass". +>> ERROR at line 26: Identifier "CONSTANT" is not a preloaded script or class. +>> ERROR at line 29: Cyclic inheritance. diff --git a/modules/gdscript/tests/scripts/analyzer/errors/abstract_class_instantiate.gd b/modules/gdscript/tests/scripts/analyzer/errors/invalid_instantiation.gd similarity index 87% rename from modules/gdscript/tests/scripts/analyzer/errors/abstract_class_instantiate.gd rename to modules/gdscript/tests/scripts/analyzer/errors/invalid_instantiation.gd index afb4b332ab0..d5b26bcdb21 100644 --- a/modules/gdscript/tests/scripts/analyzer/errors/abstract_class_instantiate.gd +++ b/modules/gdscript/tests/scripts/analyzer/errors/invalid_instantiation.gd @@ -1,10 +1,11 @@ class A extends InstancePlaceholder: func _init(): - print('no') + pass class B extends A: pass func test(): + Time.new() InstancePlaceholder.new() B.new() diff --git a/modules/gdscript/tests/scripts/analyzer/errors/invalid_instantiation.out b/modules/gdscript/tests/scripts/analyzer/errors/invalid_instantiation.out new file mode 100644 index 00000000000..c7bc46525f6 --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/errors/invalid_instantiation.out @@ -0,0 +1,6 @@ +GDTEST_ANALYZER_ERROR +>> ERROR at line 9: Cannot construct native class "Time" because it is an engine singleton. +>> ERROR at line 10: Native class "InstancePlaceholder" cannot be constructed as it is abstract. +>> ERROR at line 10: Name "new" is a Callable. You can call it with "new.call()" instead. +>> ERROR at line 11: Class "invalid_instantiation.gd::B" cannot be constructed as it is based on abstract native class "InstancePlaceholder". +>> ERROR at line 11: Name "new" is a Callable. You can call it with "new.call()" instead. diff --git a/modules/gdscript/tests/scripts/analyzer/errors/invalid_member_usage.gd b/modules/gdscript/tests/scripts/analyzer/errors/invalid_member_usage.gd new file mode 100644 index 00000000000..50888124551 --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/errors/invalid_member_usage.gd @@ -0,0 +1,14 @@ +# In 3.x there are warnings `CONSTANT_USED_AS_FUNCTION`, `FUNCTION_USED_AS_PROPERTY`, and `PROPERTY_USED_AS_FUNCTION`. +# In 4.x they are deprecated because either an error is produced or a `Callable` is returned. + +const CONSTANT = 25 + +var property = 25 + +func function(): + pass + +func test(): + function = 25 + CONSTANT(123) + property() diff --git a/modules/gdscript/tests/scripts/analyzer/errors/invalid_member_usage.out b/modules/gdscript/tests/scripts/analyzer/errors/invalid_member_usage.out new file mode 100644 index 00000000000..a6bb81f7e27 --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/errors/invalid_member_usage.out @@ -0,0 +1,6 @@ +GDTEST_ANALYZER_ERROR +>> ERROR at line 12: Cannot assign a new value to a constant. +>> ERROR at line 13: Member "CONSTANT" is not a function. +>> ERROR at line 13: Name "CONSTANT" called as a function but is a "int". +>> ERROR at line 14: Member "property" is not a function. +>> ERROR at line 14: Name "property" called as a function but is a "int". diff --git a/modules/gdscript/tests/scripts/analyzer/errors/invalid_return.gd b/modules/gdscript/tests/scripts/analyzer/errors/invalid_return.gd new file mode 100644 index 00000000000..9d2c461ce0e --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/errors/invalid_return.gd @@ -0,0 +1,22 @@ +static func _static_init() -> int: + pass + +func _init() -> int: + pass + +func f() -> void: + return null + +func g() -> void: + var a + a = 1 + return a + +func test(): + var lambda_1 := func() -> int: + print("no return") + lambda_1.call() + + var lambda_2 := func() -> int: + return "string" + lambda_2.call() diff --git a/modules/gdscript/tests/scripts/analyzer/errors/invalid_return.out b/modules/gdscript/tests/scripts/analyzer/errors/invalid_return.out new file mode 100644 index 00000000000..206f9b4b671 --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/errors/invalid_return.out @@ -0,0 +1,8 @@ +GDTEST_ANALYZER_ERROR +>> ERROR at line 1: Static constructor cannot have an explicit return type. +>> ERROR at line 4: Constructor cannot have an explicit return type. +>> ERROR at line 8: A void function cannot return a value. +>> ERROR at line 13: A void function cannot return a value. +>> ERROR at line 16: Not all code paths return a value. +>> ERROR at line 21: Cannot return a value of type "String" as "int". +>> ERROR at line 21: Cannot return value of type "String" because the function return type is "int". diff --git a/modules/gdscript/tests/scripts/analyzer/errors/lambda_cyclic_ref_call_arg.gd b/modules/gdscript/tests/scripts/analyzer/errors/lambda_cyclic_ref_call_arg.gd deleted file mode 100644 index 4b72fb9daa2..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/lambda_cyclic_ref_call_arg.gd +++ /dev/null @@ -1,5 +0,0 @@ -var f = (func (_a): return 0).call(x) -var x = f - -func test(): - pass diff --git a/modules/gdscript/tests/scripts/analyzer/errors/lambda_cyclic_ref_call_arg.out b/modules/gdscript/tests/scripts/analyzer/errors/lambda_cyclic_ref_call_arg.out deleted file mode 100644 index e439b4eefeb..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/lambda_cyclic_ref_call_arg.out +++ /dev/null @@ -1,3 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 2: Could not resolve member "f": Cyclic reference. ->> ERROR at line 2: Could not resolve type for variable "x". diff --git a/modules/gdscript/tests/scripts/analyzer/errors/lambda_cyclic_ref_param.gd b/modules/gdscript/tests/scripts/analyzer/errors/lambda_cyclic_ref_param.gd deleted file mode 100644 index 115e8be50a7..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/lambda_cyclic_ref_param.gd +++ /dev/null @@ -1,5 +0,0 @@ -var f = func (_a = x): return 0 -var x = f - -func test(): - pass diff --git a/modules/gdscript/tests/scripts/analyzer/errors/lambda_cyclic_ref_param.out b/modules/gdscript/tests/scripts/analyzer/errors/lambda_cyclic_ref_param.out deleted file mode 100644 index e439b4eefeb..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/lambda_cyclic_ref_param.out +++ /dev/null @@ -1,3 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 2: Could not resolve member "f": Cyclic reference. ->> ERROR at line 2: Could not resolve type for variable "x". diff --git a/modules/gdscript/tests/scripts/analyzer/errors/lambda_no_return.gd b/modules/gdscript/tests/scripts/analyzer/errors/lambda_no_return.gd deleted file mode 100644 index 70973c33d4e..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/lambda_no_return.gd +++ /dev/null @@ -1,4 +0,0 @@ -func test(): - var lambda := func() -> int: - print('no return') - lambda.call() diff --git a/modules/gdscript/tests/scripts/analyzer/errors/lambda_no_return.out b/modules/gdscript/tests/scripts/analyzer/errors/lambda_no_return.out deleted file mode 100644 index 4b09b694b7b..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/lambda_no_return.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 2: Not all code paths return a value. diff --git a/modules/gdscript/tests/scripts/analyzer/errors/lambda_wrong_return.gd b/modules/gdscript/tests/scripts/analyzer/errors/lambda_wrong_return.gd deleted file mode 100644 index 3c247a5b02d..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/lambda_wrong_return.gd +++ /dev/null @@ -1,4 +0,0 @@ -func test(): - var lambda := func() -> int: - return 'string' - print(lambda.call()) diff --git a/modules/gdscript/tests/scripts/analyzer/errors/lambda_wrong_return.out b/modules/gdscript/tests/scripts/analyzer/errors/lambda_wrong_return.out deleted file mode 100644 index d79f79d678c..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/lambda_wrong_return.out +++ /dev/null @@ -1,3 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 3: Cannot return a value of type "String" as "int". ->> ERROR at line 3: Cannot return value of type "String" because the function return type is "int". diff --git a/modules/gdscript/tests/scripts/analyzer/errors/local_const_as_type.gd b/modules/gdscript/tests/scripts/analyzer/errors/local_const_as_type.gd new file mode 100644 index 00000000000..bd9da2806bf --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/errors/local_const_as_type.gd @@ -0,0 +1,11 @@ +enum MyEnum { A } + +func test(): + var use_before_declared: EnumType + const EnumType = MyEnum + + var enum_variable = MyEnum + var use_non_constant: enum_variable + + const ENUM_VALUE = MyEnum.A + var use_not_type: ENUM_VALUE diff --git a/modules/gdscript/tests/scripts/analyzer/errors/local_const_as_type.out b/modules/gdscript/tests/scripts/analyzer/errors/local_const_as_type.out new file mode 100644 index 00000000000..13bc189ecae --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/errors/local_const_as_type.out @@ -0,0 +1,4 @@ +GDTEST_ANALYZER_ERROR +>> ERROR at line 4: Local constant "EnumType" is not resolved at this point. +>> ERROR at line 8: Local variable "enum_variable" cannot be used as a type. +>> ERROR at line 11: Local constant "ENUM_VALUE" is not a valid type. diff --git a/modules/gdscript/tests/scripts/analyzer/errors/local_const_as_type_use_before_declared.gd b/modules/gdscript/tests/scripts/analyzer/errors/local_const_as_type_use_before_declared.gd deleted file mode 100644 index 7cdc14685f0..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/local_const_as_type_use_before_declared.gd +++ /dev/null @@ -1,5 +0,0 @@ -enum MyEnum {} - -func test(): - var e: E - const E = MyEnum diff --git a/modules/gdscript/tests/scripts/analyzer/errors/local_const_as_type_use_before_declared.out b/modules/gdscript/tests/scripts/analyzer/errors/local_const_as_type_use_before_declared.out deleted file mode 100644 index bf38c6a9b49..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/local_const_as_type_use_before_declared.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 4: Local constant "E" is not resolved at this point. diff --git a/modules/gdscript/tests/scripts/analyzer/errors/local_const_as_type_use_not_const.gd b/modules/gdscript/tests/scripts/analyzer/errors/local_const_as_type_use_not_const.gd deleted file mode 100644 index 68cf5efd8b1..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/local_const_as_type_use_not_const.gd +++ /dev/null @@ -1,5 +0,0 @@ -enum MyEnum {} - -func test(): - var E = MyEnum - var e: E diff --git a/modules/gdscript/tests/scripts/analyzer/errors/local_const_as_type_use_not_const.out b/modules/gdscript/tests/scripts/analyzer/errors/local_const_as_type_use_not_const.out deleted file mode 100644 index 5658a715a6f..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/local_const_as_type_use_not_const.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 5: Local variable "E" cannot be used as a type. diff --git a/modules/gdscript/tests/scripts/analyzer/errors/local_const_as_type_use_not_type.gd b/modules/gdscript/tests/scripts/analyzer/errors/local_const_as_type_use_not_type.gd deleted file mode 100644 index ac446183cb0..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/local_const_as_type_use_not_type.gd +++ /dev/null @@ -1,5 +0,0 @@ -enum MyEnum {A} - -func test(): - const E = MyEnum.A - var e: E diff --git a/modules/gdscript/tests/scripts/analyzer/errors/local_const_as_type_use_not_type.out b/modules/gdscript/tests/scripts/analyzer/errors/local_const_as_type_use_not_type.out deleted file mode 100644 index 1735986fbb6..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/local_const_as_type_use_not_type.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 5: Local constant "E" is not a valid type. diff --git a/modules/gdscript/tests/scripts/analyzer/errors/match.gd b/modules/gdscript/tests/scripts/analyzer/errors/match.gd new file mode 100644 index 00000000000..5ac518c8360 --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/errors/match.gd @@ -0,0 +1,10 @@ +func test(): + var dict = { a = 1 } + var a = 1 + match 2: + dict["a"]: # TODO: Fix positional information (parser bug). + print("not allowed") + a + 2: + print("not allowed") + _ when b == 0: + print("b does not exist") diff --git a/modules/gdscript/tests/scripts/analyzer/errors/match.out b/modules/gdscript/tests/scripts/analyzer/errors/match.out new file mode 100644 index 00000000000..1210ccdd993 --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/errors/match.out @@ -0,0 +1,4 @@ +GDTEST_ANALYZER_ERROR +>> ERROR at line 7: Expression in match pattern must be a constant expression, an identifier, or an attribute access ("A.B"). +>> ERROR at line 9: Identifier "b" not declared in the current scope. +>> ERROR at line 12: Expression in match pattern must be a constant expression, an identifier, or an attribute access ("A.B"). diff --git a/modules/gdscript/tests/scripts/analyzer/errors/match_guard_invalid_expression.gd b/modules/gdscript/tests/scripts/analyzer/errors/match_guard_invalid_expression.gd deleted file mode 100644 index 1dcb9fc36a0..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/match_guard_invalid_expression.gd +++ /dev/null @@ -1,4 +0,0 @@ -func test(): - match 0: - _ when a == 0: - print("a does not exist") diff --git a/modules/gdscript/tests/scripts/analyzer/errors/match_guard_invalid_expression.out b/modules/gdscript/tests/scripts/analyzer/errors/match_guard_invalid_expression.out deleted file mode 100644 index 17a9353c5c4..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/match_guard_invalid_expression.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 3: Identifier "a" not declared in the current scope. diff --git a/modules/gdscript/tests/scripts/analyzer/errors/match_with_subscript.gd b/modules/gdscript/tests/scripts/analyzer/errors/match_with_subscript.gd deleted file mode 100644 index 6d92db34c17..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/match_with_subscript.gd +++ /dev/null @@ -1,5 +0,0 @@ -func test(): - var dict = { a = 1 } - match 2: - dict["a"]: - print("not allowed") diff --git a/modules/gdscript/tests/scripts/analyzer/errors/match_with_subscript.out b/modules/gdscript/tests/scripts/analyzer/errors/match_with_subscript.out deleted file mode 100644 index 9ce8c929948..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/match_with_subscript.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 7: Expression in match pattern must be a constant expression, an identifier, or an attribute access ("A.B"). diff --git a/modules/gdscript/tests/scripts/analyzer/errors/match_with_variable_expression.gd b/modules/gdscript/tests/scripts/analyzer/errors/match_with_variable_expression.gd deleted file mode 100644 index 4df44d9ea27..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/match_with_variable_expression.gd +++ /dev/null @@ -1,5 +0,0 @@ -func test(): - var a = 1 - match 2: - a + 2: - print("not allowed") diff --git a/modules/gdscript/tests/scripts/analyzer/errors/match_with_variable_expression.out b/modules/gdscript/tests/scripts/analyzer/errors/match_with_variable_expression.out deleted file mode 100644 index b9a207917fc..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/match_with_variable_expression.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 4: Expression in match pattern must be a constant expression, an identifier, or an attribute access ("A.B"). diff --git a/modules/gdscript/tests/scripts/analyzer/errors/native_type_errors.gd b/modules/gdscript/tests/scripts/analyzer/errors/not_found_member.gd similarity index 100% rename from modules/gdscript/tests/scripts/analyzer/errors/native_type_errors.gd rename to modules/gdscript/tests/scripts/analyzer/errors/not_found_member.gd diff --git a/modules/gdscript/tests/scripts/analyzer/errors/native_type_errors.out b/modules/gdscript/tests/scripts/analyzer/errors/not_found_member.out similarity index 100% rename from modules/gdscript/tests/scripts/analyzer/errors/native_type_errors.out rename to modules/gdscript/tests/scripts/analyzer/errors/not_found_member.out diff --git a/modules/gdscript/tests/scripts/analyzer/errors/preload_enum_error.gd b/modules/gdscript/tests/scripts/analyzer/errors/preload_enum_error.gd deleted file mode 100644 index c84a4ad8afa..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/preload_enum_error.gd +++ /dev/null @@ -1,6 +0,0 @@ -enum LocalNamed { VALUE_A, VALUE_B, VALUE_C = 42 } - -func test(): - const P = preload("../features/enum_from_outer.gd") - var x: LocalNamed - x = P.Named.VALUE_A diff --git a/modules/gdscript/tests/scripts/analyzer/errors/preload_enum_error.out b/modules/gdscript/tests/scripts/analyzer/errors/preload_enum_error.out deleted file mode 100644 index 3c066236b1a..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/preload_enum_error.out +++ /dev/null @@ -1,3 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 6: Cannot assign a value of type "enum_from_outer.gd.Named" as "preload_enum_error.gd.LocalNamed". ->> ERROR at line 6: Value of type "enum_from_outer.gd.Named" cannot be assigned to a variable of type "preload_enum_error.gd.LocalNamed". diff --git a/modules/gdscript/tests/scripts/analyzer/errors/properties.gd b/modules/gdscript/tests/scripts/analyzer/errors/properties.gd new file mode 100644 index 00000000000..2b3e2802f9a --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/errors/properties.gd @@ -0,0 +1,29 @@ +var _prop: int + +# Inline setter assigns `String` to `int`. +# Inline getter returns `int` instead of `String`. +var prop_1: String: + set(value): + _prop = value + get: + return _prop + +# Setter function has wrong argument type. +# Getter function has wrong return type. +var prop_2: String: + set = set_prop_2, get = get_prop_2 + +# Inline setter parameter uses property type. +var prop_3 := 0: + set(value): + var x: String = value + prop_3 = value + +func set_prop_2(value: int): + _prop = value + +func get_prop_2(): + return _prop + +func test(): + pass diff --git a/modules/gdscript/tests/scripts/analyzer/errors/properties.out b/modules/gdscript/tests/scripts/analyzer/errors/properties.out new file mode 100644 index 00000000000..a51513defbf --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/errors/properties.out @@ -0,0 +1,6 @@ +GDTEST_ANALYZER_ERROR +>> ERROR at line 7: Value of type "String" cannot be assigned to a variable of type "int". +>> ERROR at line 9: Cannot return value of type "int" because the function return type is "String". +>> ERROR at line 13: Function with return type "int" cannot be used as getter for a property of type "String". +>> ERROR at line 13: Function with argument type "int" cannot be used as setter for a property of type "String". +>> ERROR at line 19: Cannot assign a value of type int to variable "x" with specified type String. diff --git a/modules/gdscript/tests/scripts/analyzer/errors/property_function_get_type_error.gd b/modules/gdscript/tests/scripts/analyzer/errors/property_function_get_type_error.gd deleted file mode 100644 index 35f506aabd1..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/property_function_get_type_error.gd +++ /dev/null @@ -1,11 +0,0 @@ -var _prop: int - -# Getter function has wrong return type. -var prop: String: - get = get_prop - -func get_prop(): - return _prop - -func test(): - pass diff --git a/modules/gdscript/tests/scripts/analyzer/errors/property_function_get_type_error.out b/modules/gdscript/tests/scripts/analyzer/errors/property_function_get_type_error.out deleted file mode 100644 index 7e0cadd0127..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/property_function_get_type_error.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 4: Function with return type "int" cannot be used as getter for a property of type "String". diff --git a/modules/gdscript/tests/scripts/analyzer/errors/property_function_set_type_error.gd b/modules/gdscript/tests/scripts/analyzer/errors/property_function_set_type_error.gd deleted file mode 100644 index eedeea915d5..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/property_function_set_type_error.gd +++ /dev/null @@ -1,11 +0,0 @@ -var _prop: int - -# Setter function has wrong argument type. -var prop: String: - set = set_prop - -func set_prop(value: int): - _prop = value - -func test(): - pass diff --git a/modules/gdscript/tests/scripts/analyzer/errors/property_function_set_type_error.out b/modules/gdscript/tests/scripts/analyzer/errors/property_function_set_type_error.out deleted file mode 100644 index 1374a73df1a..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/property_function_set_type_error.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 4: Function with argument type "int" cannot be used as setter for a property of type "String". diff --git a/modules/gdscript/tests/scripts/analyzer/errors/property_inline_get_type_error.gd b/modules/gdscript/tests/scripts/analyzer/errors/property_inline_get_type_error.gd deleted file mode 100644 index 90b00fbe13d..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/property_inline_get_type_error.gd +++ /dev/null @@ -1,9 +0,0 @@ -var _prop: int - -# Inline getter returns int instead of String. -var prop: String: - get: - return _prop - -func test(): - pass diff --git a/modules/gdscript/tests/scripts/analyzer/errors/property_inline_get_type_error.out b/modules/gdscript/tests/scripts/analyzer/errors/property_inline_get_type_error.out deleted file mode 100644 index 8fe80033ea0..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/property_inline_get_type_error.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 6: Cannot return value of type "int" because the function return type is "String". diff --git a/modules/gdscript/tests/scripts/analyzer/errors/property_inline_set_type_error.gd b/modules/gdscript/tests/scripts/analyzer/errors/property_inline_set_type_error.gd deleted file mode 100644 index 5747b85fc76..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/property_inline_set_type_error.gd +++ /dev/null @@ -1,9 +0,0 @@ -var _prop: int - -# Inline setter assigns String to int. -var prop: String: - set(value): - _prop = value - -func test(): - pass diff --git a/modules/gdscript/tests/scripts/analyzer/errors/property_inline_set_type_error.out b/modules/gdscript/tests/scripts/analyzer/errors/property_inline_set_type_error.out deleted file mode 100644 index 14df30f719d..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/property_inline_set_type_error.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 6: Value of type "String" cannot be assigned to a variable of type "int". diff --git a/modules/gdscript/tests/scripts/analyzer/errors/property_used_as_function.gd b/modules/gdscript/tests/scripts/analyzer/errors/property_used_as_function.gd deleted file mode 100644 index 059d774927a..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/property_used_as_function.gd +++ /dev/null @@ -1,4 +0,0 @@ -var property = 25 - -func test(): - property() diff --git a/modules/gdscript/tests/scripts/analyzer/errors/property_used_as_function.out b/modules/gdscript/tests/scripts/analyzer/errors/property_used_as_function.out deleted file mode 100644 index d4118999c53..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/property_used_as_function.out +++ /dev/null @@ -1,3 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 4: Member "property" is not a function. ->> ERROR at line 4: Name "property" called as a function but is a "int". diff --git a/modules/gdscript/tests/scripts/analyzer/errors/redefine_class_constant.gd b/modules/gdscript/tests/scripts/analyzer/errors/redefine_class_constant.gd deleted file mode 100644 index 91401d32fca..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/redefine_class_constant.gd +++ /dev/null @@ -1,7 +0,0 @@ -# See also `parser-warnings/shadowed-constant.gd`. -const TEST = 25 - - -func test(): - # Error here (trying to set a new value to a constant). - TEST = 50 diff --git a/modules/gdscript/tests/scripts/analyzer/errors/redefine_class_constant.out b/modules/gdscript/tests/scripts/analyzer/errors/redefine_class_constant.out deleted file mode 100644 index 49a6a171d5d..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/redefine_class_constant.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 7: Cannot assign a new value to a constant. diff --git a/modules/gdscript/tests/scripts/analyzer/errors/redefine_constant.gd b/modules/gdscript/tests/scripts/analyzer/errors/redefine_constant.gd new file mode 100644 index 00000000000..e59c282e7ff --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/errors/redefine_constant.gd @@ -0,0 +1,9 @@ +# See also `parser-warnings/shadowed-constant.gd`. + +const CLASS_CONSTANT = 25 + +func test(): + const LOCAL_CONSTANT = 25 + + CLASS_CONSTANT = 50 + LOCAL_CONSTANT = 50 diff --git a/modules/gdscript/tests/scripts/analyzer/errors/redefine_constant.out b/modules/gdscript/tests/scripts/analyzer/errors/redefine_constant.out new file mode 100644 index 00000000000..785c877ea28 --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/errors/redefine_constant.out @@ -0,0 +1,3 @@ +GDTEST_ANALYZER_ERROR +>> ERROR at line 8: Cannot assign a new value to a constant. +>> ERROR at line 9: Cannot assign a new value to a constant. diff --git a/modules/gdscript/tests/scripts/analyzer/errors/redefine_local_constant.gd b/modules/gdscript/tests/scripts/analyzer/errors/redefine_local_constant.gd deleted file mode 100644 index 97f3e55e815..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/redefine_local_constant.gd +++ /dev/null @@ -1,5 +0,0 @@ -func test(): - const TEST = 25 - - # Error here (can't assign a new value to a constant). - TEST = 50 diff --git a/modules/gdscript/tests/scripts/analyzer/errors/redefine_local_constant.out b/modules/gdscript/tests/scripts/analyzer/errors/redefine_local_constant.out deleted file mode 100644 index 134de681110..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/redefine_local_constant.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 5: Cannot assign a new value to a constant. diff --git a/modules/gdscript/tests/scripts/analyzer/errors/return_null_in_void_func.gd b/modules/gdscript/tests/scripts/analyzer/errors/return_null_in_void_func.gd deleted file mode 100644 index 393b66c9f0a..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/return_null_in_void_func.gd +++ /dev/null @@ -1,2 +0,0 @@ -func test() -> void: - return null diff --git a/modules/gdscript/tests/scripts/analyzer/errors/return_null_in_void_func.out b/modules/gdscript/tests/scripts/analyzer/errors/return_null_in_void_func.out deleted file mode 100644 index 8715c79e50d..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/return_null_in_void_func.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 2: A void function cannot return a value. diff --git a/modules/gdscript/tests/scripts/analyzer/errors/return_variant_in_void_func.gd b/modules/gdscript/tests/scripts/analyzer/errors/return_variant_in_void_func.gd deleted file mode 100644 index 6be2730babf..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/return_variant_in_void_func.gd +++ /dev/null @@ -1,4 +0,0 @@ -func test() -> void: - var a - a = 1 - return a diff --git a/modules/gdscript/tests/scripts/analyzer/errors/return_variant_in_void_func.out b/modules/gdscript/tests/scripts/analyzer/errors/return_variant_in_void_func.out deleted file mode 100644 index 10ef4832e31..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/return_variant_in_void_func.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 4: A void function cannot return a value. diff --git a/modules/gdscript/tests/scripts/analyzer/errors/setter_parameter_uses_property_type.gd b/modules/gdscript/tests/scripts/analyzer/errors/setter_parameter_uses_property_type.gd deleted file mode 100644 index 3bbee5f5f77..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/setter_parameter_uses_property_type.gd +++ /dev/null @@ -1,8 +0,0 @@ -var with_setter := 0: - set(val): - var x: String = val - with_setter = val - -func test(): - with_setter = 1 - print(with_setter) diff --git a/modules/gdscript/tests/scripts/analyzer/errors/setter_parameter_uses_property_type.out b/modules/gdscript/tests/scripts/analyzer/errors/setter_parameter_uses_property_type.out deleted file mode 100644 index 83f939a3fcd..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/setter_parameter_uses_property_type.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 3: Cannot assign a value of type int to variable "x" with specified type String. diff --git a/modules/gdscript/tests/scripts/analyzer/errors/shadowing.gd b/modules/gdscript/tests/scripts/analyzer/errors/shadowing.gd new file mode 100644 index 00000000000..1011bd7630b --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/errors/shadowing.gd @@ -0,0 +1,13 @@ +class A: + enum { V } + +class B extends A: + enum { V } + +class Vector2: pass +enum Vector2i { A, B } +const Vector3 = 0 +var Vector3i + +func test(): + pass diff --git a/modules/gdscript/tests/scripts/analyzer/errors/shadowing.out b/modules/gdscript/tests/scripts/analyzer/errors/shadowing.out new file mode 100644 index 00000000000..7890486e8b8 --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/errors/shadowing.out @@ -0,0 +1,6 @@ +GDTEST_ANALYZER_ERROR +>> ERROR at line 5: The member "V" already exists in parent class A. +>> ERROR at line 7: Class "Vector2" hides a built-in type. +>> ERROR at line 8: The member "Vector2i" cannot have the same name as a builtin type. +>> ERROR at line 9: The member "Vector3" cannot have the same name as a builtin type. +>> ERROR at line 10: The member "Vector3i" cannot have the same name as a builtin type. diff --git a/modules/gdscript/tests/scripts/analyzer/errors/static_access_non_static.gd b/modules/gdscript/tests/scripts/analyzer/errors/static_access_non_static.gd new file mode 100644 index 00000000000..c416d7927e9 --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/errors/static_access_non_static.gd @@ -0,0 +1,78 @@ +# GH-83468, GH-91403 + +func non_static_func(): + pass + +static var static_var_11 = non_static_func() + +static var static_var_12: + set(_value): + var f := func (): + var g := func (): + print(non_static_func()) + g.call() + f.call() + +static var static_var_13 = func (): + var f := func (): + var g := func (): + print(non_static_func()) + g.call() + f.call() + +static var static_var_21a = non_static_func +static var static_var_21b = Callable(non_static_func) + +static var static_var_22: + set(_value): + var f := func (): + var g := func (): + print(non_static_func) + g.call() + f.call() + +static var static_var_23 = func (): + var f := func (): + var g := func (): + print(non_static_func) + g.call() + f.call() + +static func static_func_11(): + non_static_func() + +static func static_func_12(): + print(non_static_func) + +static func static_func_21(): + var f := func (): + var g := func (): + non_static_func() + g.call() + f.call() + +static func static_func_22(): + var f := func (): + var g := func (): + print(non_static_func) + g.call() + f.call() + +static func static_func_31( + f := func (): + var g := func (): + non_static_func() + g.call() +): + f.call() + +static func static_func_32( + f := func (): + var g := func (): + print(non_static_func) + g.call() +): + f.call() + +func test(): + pass diff --git a/modules/gdscript/tests/scripts/analyzer/errors/static_access_non_static.out b/modules/gdscript/tests/scripts/analyzer/errors/static_access_non_static.out new file mode 100644 index 00000000000..fa19a426570 --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/errors/static_access_non_static.out @@ -0,0 +1,14 @@ +GDTEST_ANALYZER_ERROR +>> ERROR at line 6: Cannot call non-static function "non_static_func()" from a static variable initializer. +>> ERROR at line 12: Cannot call non-static function "non_static_func()" from the static function "@static_var_12_setter()". +>> ERROR at line 19: Cannot call non-static function "non_static_func()" from a static variable initializer. +>> ERROR at line 23: Cannot access non-static function "non_static_func" from a static variable initializer. +>> ERROR at line 24: Cannot access non-static function "non_static_func" from a static variable initializer. +>> ERROR at line 30: Cannot access non-static function "non_static_func" from the static function "@static_var_22_setter()". +>> ERROR at line 37: Cannot access non-static function "non_static_func" from a static variable initializer. +>> ERROR at line 42: Cannot call non-static function "non_static_func()" from the static function "static_func_11()". +>> ERROR at line 45: Cannot access non-static function "non_static_func" from the static function "static_func_12()". +>> ERROR at line 50: Cannot call non-static function "non_static_func()" from the static function "static_func_21()". +>> ERROR at line 57: Cannot access non-static function "non_static_func" from the static function "static_func_22()". +>> ERROR at line 64: Cannot call non-static function "non_static_func()" from the static function "static_func_31()". +>> ERROR at line 72: Cannot access non-static function "non_static_func" from the static function "static_func_32()". diff --git a/modules/gdscript/tests/scripts/analyzer/errors/static_constructor_with_return_type.gd b/modules/gdscript/tests/scripts/analyzer/errors/static_constructor_with_return_type.gd deleted file mode 100644 index 3dac751ba91..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/static_constructor_with_return_type.gd +++ /dev/null @@ -1,5 +0,0 @@ -static func _static_init() -> int: - print("static init") - -func test(): - print("done") diff --git a/modules/gdscript/tests/scripts/analyzer/errors/static_constructor_with_return_type.out b/modules/gdscript/tests/scripts/analyzer/errors/static_constructor_with_return_type.out deleted file mode 100644 index 4a090598840..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/static_constructor_with_return_type.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 1: Static constructor cannot have an explicit return type. diff --git a/modules/gdscript/tests/scripts/analyzer/errors/static_func_access_non_static.gd b/modules/gdscript/tests/scripts/analyzer/errors/static_func_access_non_static.gd deleted file mode 100644 index e041aeb914d..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/static_func_access_non_static.gd +++ /dev/null @@ -1,10 +0,0 @@ -# GH-91403 - -static func static_func(): - print(non_static_func) - -func non_static_func(): - pass - -func test(): - pass diff --git a/modules/gdscript/tests/scripts/analyzer/errors/static_func_access_non_static.out b/modules/gdscript/tests/scripts/analyzer/errors/static_func_access_non_static.out deleted file mode 100644 index 9356549fdec..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/static_func_access_non_static.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 4: Cannot access non-static function "non_static_func" from the static function "static_func()". diff --git a/modules/gdscript/tests/scripts/analyzer/errors/static_func_access_non_static_in_lambda_param.gd b/modules/gdscript/tests/scripts/analyzer/errors/static_func_access_non_static_in_lambda_param.gd deleted file mode 100644 index 36bc9dbf15a..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/static_func_access_non_static_in_lambda_param.gd +++ /dev/null @@ -1,15 +0,0 @@ -# GH-91403 - -func non_static_func(): - pass - -static func static_func( - f := func (): - var g := func (): - print(non_static_func) - g.call() -): - f.call() - -func test(): - pass diff --git a/modules/gdscript/tests/scripts/analyzer/errors/static_func_access_non_static_in_lambda_param.out b/modules/gdscript/tests/scripts/analyzer/errors/static_func_access_non_static_in_lambda_param.out deleted file mode 100644 index 656b3a162ac..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/static_func_access_non_static_in_lambda_param.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 9: Cannot access non-static function "non_static_func" from the static function "static_func()". diff --git a/modules/gdscript/tests/scripts/analyzer/errors/static_func_call_non_static.gd b/modules/gdscript/tests/scripts/analyzer/errors/static_func_call_non_static.gd deleted file mode 100644 index 1d8f0768579..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/static_func_call_non_static.gd +++ /dev/null @@ -1,8 +0,0 @@ -static func static_func(): - non_static_func() - -func non_static_func(): - pass - -func test(): - pass diff --git a/modules/gdscript/tests/scripts/analyzer/errors/static_func_call_non_static.out b/modules/gdscript/tests/scripts/analyzer/errors/static_func_call_non_static.out deleted file mode 100644 index c41ce62ae36..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/static_func_call_non_static.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 2: Cannot call non-static function "non_static_func()" from the static function "static_func()". diff --git a/modules/gdscript/tests/scripts/analyzer/errors/static_func_call_non_static_in_lambda.gd b/modules/gdscript/tests/scripts/analyzer/errors/static_func_call_non_static_in_lambda.gd deleted file mode 100644 index a98f69f3acf..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/static_func_call_non_static_in_lambda.gd +++ /dev/null @@ -1,14 +0,0 @@ -# GH-83468 - -func non_static_func(): - pass - -static func static_func(): - var f := func (): - var g := func (): - non_static_func() - g.call() - f.call() - -func test(): - pass diff --git a/modules/gdscript/tests/scripts/analyzer/errors/static_func_call_non_static_in_lambda.out b/modules/gdscript/tests/scripts/analyzer/errors/static_func_call_non_static_in_lambda.out deleted file mode 100644 index ef6a1f0b133..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/static_func_call_non_static_in_lambda.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 9: Cannot call non-static function "non_static_func()" from the static function "static_func()". diff --git a/modules/gdscript/tests/scripts/analyzer/errors/static_func_call_non_static_in_lambda_param.gd b/modules/gdscript/tests/scripts/analyzer/errors/static_func_call_non_static_in_lambda_param.gd deleted file mode 100644 index 7af9ff274c0..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/static_func_call_non_static_in_lambda_param.gd +++ /dev/null @@ -1,15 +0,0 @@ -# GH-83468 - -func non_static_func(): - pass - -static func static_func( - f := func (): - var g := func (): - non_static_func() - g.call() -): - f.call() - -func test(): - pass diff --git a/modules/gdscript/tests/scripts/analyzer/errors/static_func_call_non_static_in_lambda_param.out b/modules/gdscript/tests/scripts/analyzer/errors/static_func_call_non_static_in_lambda_param.out deleted file mode 100644 index ef6a1f0b133..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/static_func_call_non_static_in_lambda_param.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 9: Cannot call non-static function "non_static_func()" from the static function "static_func()". diff --git a/modules/gdscript/tests/scripts/analyzer/errors/static_var_init_access_non_static_in_lambda.gd b/modules/gdscript/tests/scripts/analyzer/errors/static_var_init_access_non_static_in_lambda.gd deleted file mode 100644 index 7ae5bea7d77..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/static_var_init_access_non_static_in_lambda.gd +++ /dev/null @@ -1,14 +0,0 @@ -# GH-91403 - -func non_static_func(): - pass - -static var static_var = func (): - var f := func (): - var g := func (): - print(non_static_func) - g.call() - f.call() - -func test(): - pass diff --git a/modules/gdscript/tests/scripts/analyzer/errors/static_var_init_access_non_static_in_lambda.out b/modules/gdscript/tests/scripts/analyzer/errors/static_var_init_access_non_static_in_lambda.out deleted file mode 100644 index 18384570d2f..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/static_var_init_access_non_static_in_lambda.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 9: Cannot access non-static function "non_static_func" from a static variable initializer. diff --git a/modules/gdscript/tests/scripts/analyzer/errors/static_var_init_access_non_static_in_lambda_setter.gd b/modules/gdscript/tests/scripts/analyzer/errors/static_var_init_access_non_static_in_lambda_setter.gd deleted file mode 100644 index 7479afc5327..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/static_var_init_access_non_static_in_lambda_setter.gd +++ /dev/null @@ -1,15 +0,0 @@ -# GH-91403 - -func non_static_func(): - pass - -static var static_var: - set(_value): - var f := func (): - var g := func (): - print(non_static_func) - g.call() - f.call() - -func test(): - pass diff --git a/modules/gdscript/tests/scripts/analyzer/errors/static_var_init_access_non_static_in_lambda_setter.out b/modules/gdscript/tests/scripts/analyzer/errors/static_var_init_access_non_static_in_lambda_setter.out deleted file mode 100644 index 5fb76390494..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/static_var_init_access_non_static_in_lambda_setter.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 10: Cannot access non-static function "non_static_func" from the static function "@static_var_setter()". diff --git a/modules/gdscript/tests/scripts/analyzer/errors/static_var_init_call_non_static_in_lambda.gd b/modules/gdscript/tests/scripts/analyzer/errors/static_var_init_call_non_static_in_lambda.gd deleted file mode 100644 index 5130973bd2a..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/static_var_init_call_non_static_in_lambda.gd +++ /dev/null @@ -1,14 +0,0 @@ -# GH-83468 - -func non_static_func(): - pass - -static var static_var = func (): - var f := func (): - var g := func (): - non_static_func() - g.call() - f.call() - -func test(): - pass diff --git a/modules/gdscript/tests/scripts/analyzer/errors/static_var_init_call_non_static_in_lambda.out b/modules/gdscript/tests/scripts/analyzer/errors/static_var_init_call_non_static_in_lambda.out deleted file mode 100644 index 1107a2b73e3..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/static_var_init_call_non_static_in_lambda.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 9: Cannot call non-static function "non_static_func()" from a static variable initializer. diff --git a/modules/gdscript/tests/scripts/analyzer/errors/static_var_init_call_non_static_in_lambda_setter.gd b/modules/gdscript/tests/scripts/analyzer/errors/static_var_init_call_non_static_in_lambda_setter.gd deleted file mode 100644 index 2d15b4e3e55..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/static_var_init_call_non_static_in_lambda_setter.gd +++ /dev/null @@ -1,15 +0,0 @@ -# GH-83468 - -func non_static_func(): - pass - -static var static_var: - set(_value): - var f := func (): - var g := func (): - non_static_func() - g.call() - f.call() - -func test(): - pass diff --git a/modules/gdscript/tests/scripts/analyzer/errors/static_var_init_call_non_static_in_lambda_setter.out b/modules/gdscript/tests/scripts/analyzer/errors/static_var_init_call_non_static_in_lambda_setter.out deleted file mode 100644 index 99a6249e533..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/static_var_init_call_non_static_in_lambda_setter.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 10: Cannot call non-static function "non_static_func()" from the static function "@static_var_setter()". diff --git a/modules/gdscript/tests/scripts/analyzer/errors/static_var_init_non_static_access.gd b/modules/gdscript/tests/scripts/analyzer/errors/static_var_init_non_static_access.gd deleted file mode 100644 index a21b2c4470b..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/static_var_init_non_static_access.gd +++ /dev/null @@ -1,11 +0,0 @@ -# GH-91403 - -@static_unload - -func non_static(): - return "non static" - -static var static_var = Callable(non_static) - -func test(): - print("does not run") diff --git a/modules/gdscript/tests/scripts/analyzer/errors/static_var_init_non_static_access.out b/modules/gdscript/tests/scripts/analyzer/errors/static_var_init_non_static_access.out deleted file mode 100644 index 7a5875f85d9..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/static_var_init_non_static_access.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 8: Cannot access non-static function "non_static" from a static variable initializer. diff --git a/modules/gdscript/tests/scripts/analyzer/errors/static_var_init_non_static_call.gd b/modules/gdscript/tests/scripts/analyzer/errors/static_var_init_non_static_call.gd deleted file mode 100644 index 1ae814ea342..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/static_var_init_non_static_call.gd +++ /dev/null @@ -1,9 +0,0 @@ -@static_unload - -func non_static(): - return "non static" - -static var static_var = non_static() - -func test(): - print("does not run") diff --git a/modules/gdscript/tests/scripts/analyzer/errors/static_var_init_non_static_call.out b/modules/gdscript/tests/scripts/analyzer/errors/static_var_init_non_static_call.out deleted file mode 100644 index 78dfe4afb4e..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/static_var_init_non_static_call.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 6: Cannot call non-static function "non_static()" from a static variable initializer. diff --git a/modules/gdscript/tests/scripts/analyzer/errors/typed_array.gd b/modules/gdscript/tests/scripts/analyzer/errors/typed_array.gd new file mode 100644 index 00000000000..6998267ea32 --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/errors/typed_array.gd @@ -0,0 +1,11 @@ +func expect_typed(typed: Array[int]): + print(typed.size()) + +func test(): + var float_array: Array[float] = [1.0] + var integer := 1 + + var array_1: Array[int] = ["Hello", "World"] + var array_2: Array[int] = float_array + var array_3: Array[Object] = [integer] + expect_typed(float_array) diff --git a/modules/gdscript/tests/scripts/analyzer/errors/typed_array.out b/modules/gdscript/tests/scripts/analyzer/errors/typed_array.out new file mode 100644 index 00000000000..b1929ec6236 --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/errors/typed_array.out @@ -0,0 +1,6 @@ +GDTEST_ANALYZER_ERROR +>> ERROR at line 8: Cannot include a value of type "String" as "int". +>> ERROR at line 8: Cannot have an element of type "String" in an array of type "Array[int]". +>> ERROR at line 9: Cannot assign a value of type Array[float] to variable "array_2" with specified type Array[int]. +>> ERROR at line 10: Cannot have an element of type "int" in an array of type "Array[Object]". +>> ERROR at line 11: Invalid argument for "expect_typed()" function: argument 1 should be "Array[int]" but is "Array[float]". diff --git a/modules/gdscript/tests/scripts/analyzer/errors/typed_array_assign_differently_typed.gd b/modules/gdscript/tests/scripts/analyzer/errors/typed_array_assign_differently_typed.gd deleted file mode 100644 index ce50cccb3cf..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/typed_array_assign_differently_typed.gd +++ /dev/null @@ -1,4 +0,0 @@ -func test(): - var differently: Array[float] = [1.0] - var typed: Array[int] = differently - print('not ok') diff --git a/modules/gdscript/tests/scripts/analyzer/errors/typed_array_assign_differently_typed.out b/modules/gdscript/tests/scripts/analyzer/errors/typed_array_assign_differently_typed.out deleted file mode 100644 index 47a2847ebff..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/typed_array_assign_differently_typed.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 3: Cannot assign a value of type Array[float] to variable "typed" with specified type Array[int]. diff --git a/modules/gdscript/tests/scripts/analyzer/errors/typed_array_assignment.gd b/modules/gdscript/tests/scripts/analyzer/errors/typed_array_assignment.gd deleted file mode 100644 index 9f86d0531ca..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/typed_array_assignment.gd +++ /dev/null @@ -1,2 +0,0 @@ -func test(): - const arr: Array[int] = ["Hello", "World"] diff --git a/modules/gdscript/tests/scripts/analyzer/errors/typed_array_assignment.out b/modules/gdscript/tests/scripts/analyzer/errors/typed_array_assignment.out deleted file mode 100644 index 38b2727cc2d..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/typed_array_assignment.out +++ /dev/null @@ -1,3 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 2: Cannot include a value of type "String" as "int". ->> ERROR at line 2: Cannot have an element of type "String" in an array of type "Array[int]". diff --git a/modules/gdscript/tests/scripts/analyzer/errors/typed_array_init_with_unconvertable_in_literal.gd b/modules/gdscript/tests/scripts/analyzer/errors/typed_array_init_with_unconvertable_in_literal.gd deleted file mode 100644 index 7cc5aaf44fa..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/typed_array_init_with_unconvertable_in_literal.gd +++ /dev/null @@ -1,4 +0,0 @@ -func test(): - var unconvertible := 1 - var typed: Array[Object] = [unconvertible] - print('not ok') diff --git a/modules/gdscript/tests/scripts/analyzer/errors/typed_array_init_with_unconvertable_in_literal.out b/modules/gdscript/tests/scripts/analyzer/errors/typed_array_init_with_unconvertable_in_literal.out deleted file mode 100644 index b9884a9d37f..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/typed_array_init_with_unconvertable_in_literal.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 3: Cannot have an element of type "int" in an array of type "Array[Object]". diff --git a/modules/gdscript/tests/scripts/analyzer/errors/typed_array_pass_differently_to_typed.gd b/modules/gdscript/tests/scripts/analyzer/errors/typed_array_pass_differently_to_typed.gd deleted file mode 100644 index 1a90bd121e7..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/typed_array_pass_differently_to_typed.gd +++ /dev/null @@ -1,7 +0,0 @@ -func expect_typed(typed: Array[int]): - print(typed.size()) - -func test(): - var differently: Array[float] = [1.0] - expect_typed(differently) - print('not ok') diff --git a/modules/gdscript/tests/scripts/analyzer/errors/typed_array_pass_differently_to_typed.out b/modules/gdscript/tests/scripts/analyzer/errors/typed_array_pass_differently_to_typed.out deleted file mode 100644 index cd6c09a484d..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/typed_array_pass_differently_to_typed.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 6: Invalid argument for "expect_typed()" function: argument 1 should be "Array[int]" but is "Array[float]". diff --git a/modules/gdscript/tests/scripts/analyzer/errors/typed_dictionary.gd b/modules/gdscript/tests/scripts/analyzer/errors/typed_dictionary.gd new file mode 100644 index 00000000000..e88076500c5 --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/errors/typed_dictionary.gd @@ -0,0 +1,11 @@ +func expect_typed(typed: Dictionary[int, int]): + print(typed.size()) + +func test(): + var float_dict: Dictionary[float, float] = { 1.0: 0.0 } + var integer := 1 + + var dict_1: Dictionary[int, int] = { "Hello": "World" } + var dict_2: Dictionary[int, int] = float_dict + var dict_3: Dictionary[Object, Object] = { integer: integer } + expect_typed(float_dict) diff --git a/modules/gdscript/tests/scripts/analyzer/errors/typed_dictionary.out b/modules/gdscript/tests/scripts/analyzer/errors/typed_dictionary.out new file mode 100644 index 00000000000..0edd78ad6b0 --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/errors/typed_dictionary.out @@ -0,0 +1,6 @@ +GDTEST_ANALYZER_ERROR +>> ERROR at line 8: Cannot include a value of type "String" as "int". +>> ERROR at line 8: Cannot have a key of type "String" in a dictionary of type "Dictionary[int, int]". +>> ERROR at line 9: Cannot assign a value of type Dictionary[float, float] to variable "dict_2" with specified type Dictionary[int, int]. +>> ERROR at line 10: Cannot have a key of type "int" in a dictionary of type "Dictionary[Object, Object]". +>> ERROR at line 11: Invalid argument for "expect_typed()" function: argument 1 should be "Dictionary[int, int]" but is "Dictionary[float, float]". diff --git a/modules/gdscript/tests/scripts/analyzer/errors/typed_dictionary_assign_differently_typed.gd b/modules/gdscript/tests/scripts/analyzer/errors/typed_dictionary_assign_differently_typed.gd deleted file mode 100644 index 75d1b7fe629..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/typed_dictionary_assign_differently_typed.gd +++ /dev/null @@ -1,4 +0,0 @@ -func test(): - var differently: Dictionary[float, float] = { 1.0: 0.0 } - var typed: Dictionary[int, int] = differently - print('not ok') diff --git a/modules/gdscript/tests/scripts/analyzer/errors/typed_dictionary_assign_differently_typed.out b/modules/gdscript/tests/scripts/analyzer/errors/typed_dictionary_assign_differently_typed.out deleted file mode 100644 index a9cc45baa6d..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/typed_dictionary_assign_differently_typed.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 3: Cannot assign a value of type Dictionary[float, float] to variable "typed" with specified type Dictionary[int, int]. diff --git a/modules/gdscript/tests/scripts/analyzer/errors/typed_dictionary_assignment.gd b/modules/gdscript/tests/scripts/analyzer/errors/typed_dictionary_assignment.gd deleted file mode 100644 index e0af71823ae..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/typed_dictionary_assignment.gd +++ /dev/null @@ -1,2 +0,0 @@ -func test(): - const dict: Dictionary[int, int] = { "Hello": "World" } diff --git a/modules/gdscript/tests/scripts/analyzer/errors/typed_dictionary_assignment.out b/modules/gdscript/tests/scripts/analyzer/errors/typed_dictionary_assignment.out deleted file mode 100644 index 96ee8d3687e..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/typed_dictionary_assignment.out +++ /dev/null @@ -1,3 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 2: Cannot include a value of type "String" as "int". ->> ERROR at line 2: Cannot have a key of type "String" in a dictionary of type "Dictionary[int, int]". diff --git a/modules/gdscript/tests/scripts/analyzer/errors/typed_dictionary_init_with_unconvertible_in_literal.gd b/modules/gdscript/tests/scripts/analyzer/errors/typed_dictionary_init_with_unconvertible_in_literal.gd deleted file mode 100644 index 814ba12aef1..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/typed_dictionary_init_with_unconvertible_in_literal.gd +++ /dev/null @@ -1,4 +0,0 @@ -func test(): - var unconvertible := 1 - var typed: Dictionary[Object, Object] = { unconvertible: unconvertible } - print('not ok') diff --git a/modules/gdscript/tests/scripts/analyzer/errors/typed_dictionary_init_with_unconvertible_in_literal.out b/modules/gdscript/tests/scripts/analyzer/errors/typed_dictionary_init_with_unconvertible_in_literal.out deleted file mode 100644 index 7a36ca7ebd5..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/typed_dictionary_init_with_unconvertible_in_literal.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 3: Cannot have a key of type "int" in a dictionary of type "Dictionary[Object, Object]". diff --git a/modules/gdscript/tests/scripts/analyzer/errors/typed_dictionary_pass_differently_to_typed.gd b/modules/gdscript/tests/scripts/analyzer/errors/typed_dictionary_pass_differently_to_typed.gd deleted file mode 100644 index 73d8ce2b96e..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/typed_dictionary_pass_differently_to_typed.gd +++ /dev/null @@ -1,7 +0,0 @@ -func expect_typed(typed: Dictionary[int, int]): - print(typed.size()) - -func test(): - var differently: Dictionary[float, float] = { 1.0: 0.0 } - expect_typed(differently) - print('not ok') diff --git a/modules/gdscript/tests/scripts/analyzer/errors/typed_dictionary_pass_differently_to_typed.out b/modules/gdscript/tests/scripts/analyzer/errors/typed_dictionary_pass_differently_to_typed.out deleted file mode 100644 index 4c9b985f9bc..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/typed_dictionary_pass_differently_to_typed.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 6: Invalid argument for "expect_typed()" function: argument 1 should be "Dictionary[int, int]" but is "Dictionary[float, float]". diff --git a/modules/gdscript/tests/scripts/analyzer/errors/use_value_of_void_function.gd b/modules/gdscript/tests/scripts/analyzer/errors/use_value_of_void_function.gd new file mode 100644 index 00000000000..c3ac90fa9ab --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/errors/use_value_of_void_function.gd @@ -0,0 +1,14 @@ +func foo() -> void: + pass + +func test(): + var array := [] + var ref_counted: Variant = RefCounted.new() + var node := Node.new() + + print(print()) # Built-in utility function. + print(print_debug()) # GDScript utility function. + print(array.reverse()) # Built-in type method. + print(ref_counted.notify_property_list_changed()) # Native type method. # TODO + print(node.free()) # `Object.free()` method. + print(foo()) # Custom method. diff --git a/modules/gdscript/tests/scripts/analyzer/errors/use_value_of_void_function.out b/modules/gdscript/tests/scripts/analyzer/errors/use_value_of_void_function.out new file mode 100644 index 00000000000..75a53cd8f18 --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/errors/use_value_of_void_function.out @@ -0,0 +1,6 @@ +GDTEST_ANALYZER_ERROR +>> ERROR at line 9: Cannot get return value of call to "print()" because it returns "void". +>> ERROR at line 10: Cannot get return value of call to "print_debug()" because it returns "void". +>> ERROR at line 11: Cannot get return value of call to "reverse()" because it returns "void". +>> ERROR at line 13: Cannot get return value of call to "free()" because it returns "void". +>> ERROR at line 14: Cannot get return value of call to "foo()" because it returns "void". diff --git a/modules/gdscript/tests/scripts/analyzer/errors/use_value_of_void_function_builtin_method.gd b/modules/gdscript/tests/scripts/analyzer/errors/use_value_of_void_function_builtin_method.gd deleted file mode 100644 index a3450966ccd..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/use_value_of_void_function_builtin_method.gd +++ /dev/null @@ -1,3 +0,0 @@ -func test(): - var builtin := [] - print(builtin.reverse()) # Built-in type method. diff --git a/modules/gdscript/tests/scripts/analyzer/errors/use_value_of_void_function_builtin_method.out b/modules/gdscript/tests/scripts/analyzer/errors/use_value_of_void_function_builtin_method.out deleted file mode 100644 index 78ae8f7ccc1..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/use_value_of_void_function_builtin_method.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 3: Cannot get return value of call to "reverse()" because it returns "void". diff --git a/modules/gdscript/tests/scripts/analyzer/errors/use_value_of_void_function_custom_method.gd b/modules/gdscript/tests/scripts/analyzer/errors/use_value_of_void_function_custom_method.gd deleted file mode 100644 index 2162a181ac1..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/use_value_of_void_function_custom_method.gd +++ /dev/null @@ -1,5 +0,0 @@ -func foo() -> void: - pass - -func test(): - print(foo()) # Custom method. diff --git a/modules/gdscript/tests/scripts/analyzer/errors/use_value_of_void_function_custom_method.out b/modules/gdscript/tests/scripts/analyzer/errors/use_value_of_void_function_custom_method.out deleted file mode 100644 index 124efa307d3..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/use_value_of_void_function_custom_method.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 5: Cannot get return value of call to "foo()" because it returns "void". diff --git a/modules/gdscript/tests/scripts/analyzer/errors/use_value_of_void_function_gd_utility.gd b/modules/gdscript/tests/scripts/analyzer/errors/use_value_of_void_function_gd_utility.gd deleted file mode 100644 index f3443d985e4..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/use_value_of_void_function_gd_utility.gd +++ /dev/null @@ -1,2 +0,0 @@ -func test(): - print(print_debug()) # GDScript utility function. diff --git a/modules/gdscript/tests/scripts/analyzer/errors/use_value_of_void_function_gd_utility.out b/modules/gdscript/tests/scripts/analyzer/errors/use_value_of_void_function_gd_utility.out deleted file mode 100644 index 1af3a0ceb55..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/use_value_of_void_function_gd_utility.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 2: Cannot get return value of call to "print_debug()" because it returns "void". diff --git a/modules/gdscript/tests/scripts/analyzer/errors/use_value_of_void_function_native_method.gd b/modules/gdscript/tests/scripts/analyzer/errors/use_value_of_void_function_native_method.gd deleted file mode 100644 index b8e81b160a5..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/use_value_of_void_function_native_method.gd +++ /dev/null @@ -1,3 +0,0 @@ -func test(): - var obj := Node.new() - print(obj.free()) # Native type method. diff --git a/modules/gdscript/tests/scripts/analyzer/errors/use_value_of_void_function_native_method.out b/modules/gdscript/tests/scripts/analyzer/errors/use_value_of_void_function_native_method.out deleted file mode 100644 index b5857adf077..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/use_value_of_void_function_native_method.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 3: Cannot get return value of call to "free()" because it returns "void". diff --git a/modules/gdscript/tests/scripts/analyzer/errors/use_value_of_void_function_utility.gd b/modules/gdscript/tests/scripts/analyzer/errors/use_value_of_void_function_utility.gd deleted file mode 100644 index 8eabed4271a..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/use_value_of_void_function_utility.gd +++ /dev/null @@ -1,2 +0,0 @@ -func test(): - print(print()) # Built-in utility function. diff --git a/modules/gdscript/tests/scripts/analyzer/errors/use_value_of_void_function_utility.out b/modules/gdscript/tests/scripts/analyzer/errors/use_value_of_void_function_utility.out deleted file mode 100644 index 9bdd3c3d2b6..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/use_value_of_void_function_utility.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 2: Cannot get return value of call to "print()" because it returns "void". diff --git a/modules/gdscript/tests/scripts/analyzer/errors/utility_function_wrong_arg.gd b/modules/gdscript/tests/scripts/analyzer/errors/utility_functions.gd similarity index 56% rename from modules/gdscript/tests/scripts/analyzer/errors/utility_function_wrong_arg.gd rename to modules/gdscript/tests/scripts/analyzer/errors/utility_functions.gd index dc6e26e6821..b90f1ac5575 100644 --- a/modules/gdscript/tests/scripts/analyzer/errors/utility_function_wrong_arg.gd +++ b/modules/gdscript/tests/scripts/analyzer/errors/utility_functions.gd @@ -1,2 +1,3 @@ func test(): print(floor(Color())) # Built-in utility function. + print(len(Color())) # GDScript utility function. diff --git a/modules/gdscript/tests/scripts/analyzer/errors/utility_function_wrong_arg.out b/modules/gdscript/tests/scripts/analyzer/errors/utility_functions.out similarity index 64% rename from modules/gdscript/tests/scripts/analyzer/errors/utility_function_wrong_arg.out rename to modules/gdscript/tests/scripts/analyzer/errors/utility_functions.out index 6369a33cd49..23fe1521b94 100644 --- a/modules/gdscript/tests/scripts/analyzer/errors/utility_function_wrong_arg.out +++ b/modules/gdscript/tests/scripts/analyzer/errors/utility_functions.out @@ -1,2 +1,3 @@ GDTEST_ANALYZER_ERROR >> ERROR at line 2: Invalid argument for "floor()" function: Argument "x" must be "int", "float", "Vector2", "Vector2i", "Vector3", "Vector3i", "Vector4", or "Vector4i". +>> ERROR at line 3: Invalid argument for "len()" function: Value of type 'Color' can't provide a length. diff --git a/modules/gdscript/tests/scripts/analyzer/errors/variable_name_shadows_builtin_type.gd b/modules/gdscript/tests/scripts/analyzer/errors/variable_name_shadows_builtin_type.gd deleted file mode 100644 index 7cba29884c6..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/variable_name_shadows_builtin_type.gd +++ /dev/null @@ -1,4 +0,0 @@ -var Vector2 - -func test(): - pass diff --git a/modules/gdscript/tests/scripts/analyzer/errors/variable_name_shadows_builtin_type.out b/modules/gdscript/tests/scripts/analyzer/errors/variable_name_shadows_builtin_type.out deleted file mode 100644 index ce8d9807b2f..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/errors/variable_name_shadows_builtin_type.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_ANALYZER_ERROR ->> ERROR at line 1: The member "Vector2" cannot have the same name as a builtin type. diff --git a/modules/gdscript/tests/scripts/analyzer/errors/variadic_functions.out b/modules/gdscript/tests/scripts/analyzer/errors/variadic_functions.out index acf67495ab4..755ae2a2894 100644 --- a/modules/gdscript/tests/scripts/analyzer/errors/variadic_functions.out +++ b/modules/gdscript/tests/scripts/analyzer/errors/variadic_functions.out @@ -1,5 +1,5 @@ GDTEST_ANALYZER_ERROR ->> ERROR at line 15: The rest parameter type must be "Array", but "int" is specified. ->> ERROR at line 18: Typed arrays are currently not supported for the rest parameter. >> ERROR at line 9: The function signature doesn't match the parent. Parent signature is "f1(int, ...) -> void". >> ERROR at line 12: The function signature doesn't match the parent. Parent signature is "f2(int, ...) -> void". +>> ERROR at line 15: The rest parameter type must be "Array", but "int" is specified. +>> ERROR at line 18: Typed arrays are currently not supported for the rest parameter. diff --git a/modules/gdscript/tests/scripts/analyzer/features/constant_expressions.gd b/modules/gdscript/tests/scripts/analyzer/features/constant_expressions.gd index deb9ed2c543..0f1a64e4f58 100644 --- a/modules/gdscript/tests/scripts/analyzer/features/constant_expressions.gd +++ b/modules/gdscript/tests/scripts/analyzer/features/constant_expressions.gd @@ -59,7 +59,7 @@ func test(): for property in get_property_list(): if str(property.name).begins_with("test_"): - Utils.print_property_extended_info(property, self) + print(Utils.get_property_extended_info(property, self)) # GH-96152 const ARRAY = [42] diff --git a/modules/gdscript/tests/scripts/analyzer/features/export_enum_as_dictionary.gd b/modules/gdscript/tests/scripts/analyzer/features/export_enum_as_dictionary.gd index ec892263283..b9560eb4208 100644 --- a/modules/gdscript/tests/scripts/analyzer/features/export_enum_as_dictionary.gd +++ b/modules/gdscript/tests/scripts/analyzer/features/export_enum_as_dictionary.gd @@ -11,4 +11,4 @@ enum MyEnum {A, B, C} func test(): for property in get_property_list(): if str(property.name).begins_with("test_"): - Utils.print_property_extended_info(property) + print(Utils.get_property_extended_info(property)) diff --git a/modules/gdscript/tests/scripts/analyzer/features/global_builtin_and_native_enums.gd b/modules/gdscript/tests/scripts/analyzer/features/global_builtin_and_native_enums.gd index 4ccd7de994f..aa970473aec 100644 --- a/modules/gdscript/tests/scripts/analyzer/features/global_builtin_and_native_enums.gd +++ b/modules/gdscript/tests/scripts/analyzer/features/global_builtin_and_native_enums.gd @@ -19,7 +19,7 @@ extends Node func test(): for property in get_property_list(): if str(property.name).begins_with("test_"): - Utils.print_property_extended_info(property, self) + print(Utils.get_property_extended_info(property, self)) func test_no_exec(): # GH-99309 diff --git a/modules/gdscript/tests/scripts/analyzer/warnings/shadowning.gd b/modules/gdscript/tests/scripts/analyzer/warnings/shadowing.gd similarity index 100% rename from modules/gdscript/tests/scripts/analyzer/warnings/shadowning.gd rename to modules/gdscript/tests/scripts/analyzer/warnings/shadowing.gd diff --git a/modules/gdscript/tests/scripts/analyzer/warnings/shadowning.out b/modules/gdscript/tests/scripts/analyzer/warnings/shadowing.out similarity index 98% rename from modules/gdscript/tests/scripts/analyzer/warnings/shadowning.out rename to modules/gdscript/tests/scripts/analyzer/warnings/shadowing.out index 702361f8a39..0c05f823eed 100644 --- a/modules/gdscript/tests/scripts/analyzer/warnings/shadowning.out +++ b/modules/gdscript/tests/scripts/analyzer/warnings/shadowing.out @@ -6,7 +6,7 @@ GDTEST_OK ~~ WARNING at line 15: (SHADOWED_GLOBAL_IDENTIFIER) The variable "sqrt" has the same name as a built-in function. ~~ WARNING at line 16: (SHADOWED_VARIABLE) The local variable "member" is shadowing an already-declared variable at line 4 in the current class. ~~ WARNING at line 17: (SHADOWED_VARIABLE_BASE_CLASS) The local variable "reference" is shadowing an already-declared method in the base class "RefCounted". -~~ WARNING at line 18: (SHADOWED_GLOBAL_IDENTIFIER) The variable "ShadowedClass" has the same name as a global class defined in "shadowning.gd". +~~ WARNING at line 18: (SHADOWED_GLOBAL_IDENTIFIER) The variable "ShadowedClass" has the same name as a global class defined in "shadowing.gd". ~~ WARNING at line 19: (SHADOWED_VARIABLE_BASE_CLASS) The local variable "base_variable_member" is shadowing an already-declared variable at line 4 in the base class "ShadowingBase". ~~ WARNING at line 20: (SHADOWED_VARIABLE_BASE_CLASS) The local constant "base_function_member" is shadowing an already-declared function at line 6 in the base class "ShadowingBase". ~~ WARNING at line 21: (SHADOWED_VARIABLE_BASE_CLASS) The local variable "base_const_member" is shadowing an already-declared constant at line 3 in the base class "ShadowingBase". diff --git a/modules/gdscript/tests/scripts/analyzer/warnings/shadowing_base.notest.gd b/modules/gdscript/tests/scripts/analyzer/warnings/shadowing_base.notest.gd index 5819246ded4..37c5e3f0bb8 100644 --- a/modules/gdscript/tests/scripts/analyzer/warnings/shadowing_base.notest.gd +++ b/modules/gdscript/tests/scripts/analyzer/warnings/shadowing_base.notest.gd @@ -4,4 +4,4 @@ const base_const_member = 1 var base_variable_member func base_function_member(): - pass + pass diff --git a/modules/gdscript/tests/scripts/parser/features/annotations.gd b/modules/gdscript/tests/scripts/parser/features/annotations.gd index 1e5d3fdcade..ef955e104fb 100644 --- a/modules/gdscript/tests/scripts/parser/features/annotations.gd +++ b/modules/gdscript/tests/scripts/parser/features/annotations.gd @@ -44,4 +44,4 @@ var test_12: int = 42 func test(): for property in get_property_list(): if str(property.name).begins_with("test_"): - Utils.print_property_extended_info(property, self) + print(Utils.get_property_extended_info(property, self)) diff --git a/modules/gdscript/tests/scripts/parser/features/export_arrays.gd b/modules/gdscript/tests/scripts/parser/features/export_arrays.gd index cfda255905f..0b70dd8646c 100644 --- a/modules/gdscript/tests/scripts/parser/features/export_arrays.gd +++ b/modules/gdscript/tests/scripts/parser/features/export_arrays.gd @@ -83,4 +83,4 @@ var temp_packed_vector4_array: PackedVector4Array func test(): for property in get_property_list(): if str(property.name).begins_with("test_"): - Utils.print_property_extended_info(property) + print(Utils.get_property_extended_info(property)) diff --git a/modules/gdscript/tests/scripts/parser/features/export_enum.gd b/modules/gdscript/tests/scripts/parser/features/export_enum.gd index d50f0b25283..8448995d4d9 100644 --- a/modules/gdscript/tests/scripts/parser/features/export_enum.gd +++ b/modules/gdscript/tests/scripts/parser/features/export_enum.gd @@ -32,4 +32,4 @@ var temp_packed_string_array: PackedStringArray func test(): for property in get_property_list(): if str(property.name).begins_with("test_"): - Utils.print_property_extended_info(property, self) + print(Utils.get_property_extended_info(property, self)) diff --git a/modules/gdscript/tests/scripts/parser/features/export_variable.gd b/modules/gdscript/tests/scripts/parser/features/export_variable.gd index 0d3cfc55da8..ff8832b691a 100644 --- a/modules/gdscript/tests/scripts/parser/features/export_variable.gd +++ b/modules/gdscript/tests/scripts/parser/features/export_variable.gd @@ -70,4 +70,4 @@ var test_custom_enum_hard_no_export: CustomEnum func test(): for property in get_property_list(): if str(property.name).begins_with("test_"): - Utils.print_property_extended_info(property, self) + print(Utils.get_property_extended_info(property, self)) diff --git a/modules/gdscript/tests/scripts/parser/features/multiline_preload.gd b/modules/gdscript/tests/scripts/parser/features/multiline_preload.gd new file mode 100644 index 00000000000..0882464cf98 --- /dev/null +++ b/modules/gdscript/tests/scripts/parser/features/multiline_preload.gd @@ -0,0 +1,15 @@ +@warning_ignore_start("return_value_discarded") + +func test(): + const PATH = "../../utils.notest.gd" + + preload(PATH) + preload(PATH,) + preload( + PATH + ) + preload( + PATH, + ) + + print("OK") diff --git a/modules/gdscript/tests/scripts/parser/features/multiline_preload.out b/modules/gdscript/tests/scripts/parser/features/multiline_preload.out new file mode 100644 index 00000000000..1ccb591560d --- /dev/null +++ b/modules/gdscript/tests/scripts/parser/features/multiline_preload.out @@ -0,0 +1,2 @@ +GDTEST_OK +OK diff --git a/modules/gdscript/tests/scripts/runtime/errors/assign_freed_instance.gd b/modules/gdscript/tests/scripts/runtime/errors/assign_freed_instance.gd index 08302930bc0..933e92b9215 100644 --- a/modules/gdscript/tests/scripts/runtime/errors/assign_freed_instance.gd +++ b/modules/gdscript/tests/scripts/runtime/errors/assign_freed_instance.gd @@ -3,19 +3,17 @@ class A extends Node: func subtest_native(): var x = Node.new() - x.free() - var _ok = x var _bad: Node = x + print("end subtest_native") func subtest_script(): var x = A.new() - x.free() - var _ok = x var _bad: A = x + print("end subtest_script") func test(): subtest_native() diff --git a/modules/gdscript/tests/scripts/runtime/errors/assign_freed_instance.out b/modules/gdscript/tests/scripts/runtime/errors/assign_freed_instance.out index 19de682c6ca..d37765bc7fd 100644 --- a/modules/gdscript/tests/scripts/runtime/errors/assign_freed_instance.out +++ b/modules/gdscript/tests/scripts/runtime/errors/assign_freed_instance.out @@ -1,3 +1,3 @@ GDTEST_RUNTIME_ERROR ->> SCRIPT ERROR at runtime/errors/assign_freed_instance.gd:10 on subtest_native(): Trying to assign invalid previously freed instance. ->> SCRIPT ERROR at runtime/errors/assign_freed_instance.gd:18 on subtest_script(): Trying to assign invalid previously freed instance. +>> SCRIPT ERROR at runtime/errors/assign_freed_instance.gd:8 on subtest_native(): Trying to assign invalid previously freed instance. +>> SCRIPT ERROR at runtime/errors/assign_freed_instance.gd:15 on subtest_script(): Trying to assign invalid previously freed instance. diff --git a/modules/gdscript/tests/scripts/runtime/errors/assign_to_read_only_property.gd b/modules/gdscript/tests/scripts/runtime/errors/assign_to_read_only_property.gd index 2b7322ad8e1..ebd037c006f 100644 --- a/modules/gdscript/tests/scripts/runtime/errors/assign_to_read_only_property.gd +++ b/modules/gdscript/tests/scripts/runtime/errors/assign_to_read_only_property.gd @@ -1,8 +1,10 @@ func subtest_attribute(state): state.center_of_mass.x -= 1.0 + print("end subtest_attribute") func subtest_variable_index(state, prop): state[prop].x = 1.0 + print("end subtest_variable_index") func test(): var state = PhysicsDirectBodyState3DExtension.new() diff --git a/modules/gdscript/tests/scripts/runtime/errors/assign_to_read_only_property.out b/modules/gdscript/tests/scripts/runtime/errors/assign_to_read_only_property.out index 3492e799ff1..b179c096166 100644 --- a/modules/gdscript/tests/scripts/runtime/errors/assign_to_read_only_property.out +++ b/modules/gdscript/tests/scripts/runtime/errors/assign_to_read_only_property.out @@ -1,6 +1,6 @@ GDTEST_RUNTIME_ERROR -~~ WARNING at line 9: (UNSAFE_CALL_ARGUMENT) The argument 1 of the function "subtest_attribute()" requires the subtype "Variant" but the supertype "Variant" was provided. -~~ WARNING at line 10: (UNSAFE_CALL_ARGUMENT) The argument 1 of the function "subtest_variable_index()" requires the subtype "Variant" but the supertype "Variant" was provided. +~~ WARNING at line 11: (UNSAFE_CALL_ARGUMENT) The argument 1 of the function "subtest_attribute()" requires the subtype "Variant" but the supertype "Variant" was provided. +~~ WARNING at line 12: (UNSAFE_CALL_ARGUMENT) The argument 1 of the function "subtest_variable_index()" requires the subtype "Variant" but the supertype "Variant" was provided. >> ERROR: Required virtual method PhysicsDirectBodyState3DExtension::_get_center_of_mass must be overridden before calling. >> SCRIPT ERROR at runtime/errors/assign_to_read_only_property.gd:2 on subtest_attribute(): Cannot set value into property "center_of_mass" (on base "PhysicsDirectBodyState3DExtension") because it is read-only. ->> SCRIPT ERROR at runtime/errors/assign_to_read_only_property.gd:5 on subtest_variable_index(): Cannot set value into property "center_of_mass" (on base "PhysicsDirectBodyState3DExtension") because it is read-only. +>> SCRIPT ERROR at runtime/errors/assign_to_read_only_property.gd:6 on subtest_variable_index(): Cannot set value into property "center_of_mass" (on base "PhysicsDirectBodyState3DExtension") because it is read-only. diff --git a/modules/gdscript/tests/scripts/runtime/errors/callable_call_after_free_object.gd b/modules/gdscript/tests/scripts/runtime/errors/callable_call_after_free_object.gd index 7b3c112fe91..a398c4cee5d 100644 --- a/modules/gdscript/tests/scripts/runtime/errors/callable_call_after_free_object.gd +++ b/modules/gdscript/tests/scripts/runtime/errors/callable_call_after_free_object.gd @@ -4,3 +4,4 @@ func test(): var inside_tree = node.is_inside_tree node.free() inside_tree.call() + print(node) diff --git a/modules/gdscript/tests/scripts/runtime/errors/cast_freed_object.gd b/modules/gdscript/tests/scripts/runtime/errors/cast_freed_object.gd deleted file mode 100644 index 6b766f4d3d0..00000000000 --- a/modules/gdscript/tests/scripts/runtime/errors/cast_freed_object.gd +++ /dev/null @@ -1,4 +0,0 @@ -func test(): - var node := Node.new() - node.free() - print(node as Node2D) diff --git a/modules/gdscript/tests/scripts/runtime/errors/cast_freed_object.out b/modules/gdscript/tests/scripts/runtime/errors/cast_freed_object.out deleted file mode 100644 index d6277056e87..00000000000 --- a/modules/gdscript/tests/scripts/runtime/errors/cast_freed_object.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_RUNTIME_ERROR ->> SCRIPT ERROR at runtime/errors/cast_freed_object.gd:4 on test(): Trying to cast a freed object. diff --git a/modules/gdscript/tests/scripts/runtime/errors/cast_int_to_array.gd b/modules/gdscript/tests/scripts/runtime/errors/cast_int_to_array.gd deleted file mode 100644 index 00817c588fa..00000000000 --- a/modules/gdscript/tests/scripts/runtime/errors/cast_int_to_array.gd +++ /dev/null @@ -1,4 +0,0 @@ -func test(): - var integer: Variant = 1 - @warning_ignore("unsafe_cast") - print(integer as Array) diff --git a/modules/gdscript/tests/scripts/runtime/errors/cast_int_to_array.out b/modules/gdscript/tests/scripts/runtime/errors/cast_int_to_array.out deleted file mode 100644 index 43b413c205e..00000000000 --- a/modules/gdscript/tests/scripts/runtime/errors/cast_int_to_array.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_RUNTIME_ERROR ->> SCRIPT ERROR at runtime/errors/cast_int_to_array.gd:4 on test(): Invalid cast: could not convert value to 'Array'. diff --git a/modules/gdscript/tests/scripts/runtime/errors/cast_int_to_object.gd b/modules/gdscript/tests/scripts/runtime/errors/cast_int_to_object.gd deleted file mode 100644 index 44673a45137..00000000000 --- a/modules/gdscript/tests/scripts/runtime/errors/cast_int_to_object.gd +++ /dev/null @@ -1,4 +0,0 @@ -func test(): - var integer: Variant = 1 - @warning_ignore("unsafe_cast") - print(integer as Node) diff --git a/modules/gdscript/tests/scripts/runtime/errors/cast_int_to_object.out b/modules/gdscript/tests/scripts/runtime/errors/cast_int_to_object.out deleted file mode 100644 index 42fef6ba949..00000000000 --- a/modules/gdscript/tests/scripts/runtime/errors/cast_int_to_object.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_RUNTIME_ERROR ->> SCRIPT ERROR at runtime/errors/cast_int_to_object.gd:4 on test(): Invalid cast: can't convert a non-object value to an object type. diff --git a/modules/gdscript/tests/scripts/runtime/errors/cast_object_to_int.gd b/modules/gdscript/tests/scripts/runtime/errors/cast_object_to_int.gd deleted file mode 100644 index 830d0c0c4ac..00000000000 --- a/modules/gdscript/tests/scripts/runtime/errors/cast_object_to_int.gd +++ /dev/null @@ -1,4 +0,0 @@ -func test(): - var object: Variant = RefCounted.new() - @warning_ignore("unsafe_cast") - print(object as int) diff --git a/modules/gdscript/tests/scripts/runtime/errors/cast_object_to_int.out b/modules/gdscript/tests/scripts/runtime/errors/cast_object_to_int.out deleted file mode 100644 index 205727808e0..00000000000 --- a/modules/gdscript/tests/scripts/runtime/errors/cast_object_to_int.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_RUNTIME_ERROR ->> SCRIPT ERROR at runtime/errors/cast_object_to_int.gd:4 on test(): Invalid cast: could not convert value to 'int'. diff --git a/modules/gdscript/tests/scripts/runtime/errors/constant_array_is_deep.gd b/modules/gdscript/tests/scripts/runtime/errors/constant_array_is_deep.gd deleted file mode 100644 index a5ecaba38df..00000000000 --- a/modules/gdscript/tests/scripts/runtime/errors/constant_array_is_deep.gd +++ /dev/null @@ -1,6 +0,0 @@ -const array: Array = [{}] - -func test(): - var dictionary := array[0] - var key: int = 0 - dictionary[key] = 0 diff --git a/modules/gdscript/tests/scripts/runtime/errors/constant_array_is_deep.out b/modules/gdscript/tests/scripts/runtime/errors/constant_array_is_deep.out deleted file mode 100644 index ccd0da39ad6..00000000000 --- a/modules/gdscript/tests/scripts/runtime/errors/constant_array_is_deep.out +++ /dev/null @@ -1,4 +0,0 @@ -GDTEST_RUNTIME_ERROR ->> ERROR: Condition "_p->read_only" is true. Returning: false ->> Dictionary is in read-only state. ->> SCRIPT ERROR at runtime/errors/constant_array_is_deep.gd:6 on test(): Invalid assignment on read-only value (on base: 'Dictionary'). diff --git a/modules/gdscript/tests/scripts/runtime/errors/constant_collections.gd b/modules/gdscript/tests/scripts/runtime/errors/constant_collections.gd new file mode 100644 index 00000000000..f6e776d8b48 --- /dev/null +++ b/modules/gdscript/tests/scripts/runtime/errors/constant_collections.gd @@ -0,0 +1,32 @@ +const ARRAY := [{}] +const DICTIONARY := { 0: [0] } + +func subtest_constant_array(): + var dictionary := ARRAY[0] + var key := 0 + dictionary[key] = 0 + print(ARRAY) + +func subtest_constant_dictionary(): + var array := DICTIONARY[0] + var key := 0 + array[key] = 0 + print(DICTIONARY) + +func subtest_readonly_array(): + var array := [0] + array.make_read_only() + array[0] = 1 + print(array) + +func subtest_readonly_dictionary(): + var dictionary := { "a": 0 } + dictionary.make_read_only() + dictionary.a = 1 + print(dictionary) + +func test(): + subtest_constant_array() + subtest_constant_dictionary() + subtest_readonly_array() + subtest_readonly_dictionary() diff --git a/modules/gdscript/tests/scripts/runtime/errors/constant_collections.out b/modules/gdscript/tests/scripts/runtime/errors/constant_collections.out new file mode 100644 index 00000000000..203aced532f --- /dev/null +++ b/modules/gdscript/tests/scripts/runtime/errors/constant_collections.out @@ -0,0 +1,9 @@ +GDTEST_RUNTIME_ERROR +>> ERROR: Condition "_p->read_only" is true. Returning: false +>> Dictionary is in read-only state. +>> SCRIPT ERROR at runtime/errors/constant_collections.gd:7 on subtest_constant_array(): Invalid assignment on read-only value (on base: 'Dictionary'). +>> SCRIPT ERROR at runtime/errors/constant_collections.gd:13 on subtest_constant_dictionary(): Invalid assignment on read-only value (on base: 'Array'). +>> SCRIPT ERROR at runtime/errors/constant_collections.gd:19 on subtest_readonly_array(): Invalid assignment on read-only value (on base: 'Array'). +>> ERROR: Condition "_p->read_only" is true. Returning: false +>> Dictionary is in read-only state. +>> SCRIPT ERROR at runtime/errors/constant_collections.gd:25 on subtest_readonly_dictionary(): Invalid assignment on read-only value (on base: 'Dictionary'). diff --git a/modules/gdscript/tests/scripts/runtime/errors/constant_dictionary_is_deep.gd b/modules/gdscript/tests/scripts/runtime/errors/constant_dictionary_is_deep.gd deleted file mode 100644 index 4763210a7f1..00000000000 --- a/modules/gdscript/tests/scripts/runtime/errors/constant_dictionary_is_deep.gd +++ /dev/null @@ -1,6 +0,0 @@ -const dictionary := {0: [0]} - -func test(): - var array := dictionary[0] - var key: int = 0 - array[key] = 0 diff --git a/modules/gdscript/tests/scripts/runtime/errors/constant_dictionary_is_deep.out b/modules/gdscript/tests/scripts/runtime/errors/constant_dictionary_is_deep.out deleted file mode 100644 index 9f7965de38b..00000000000 --- a/modules/gdscript/tests/scripts/runtime/errors/constant_dictionary_is_deep.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_RUNTIME_ERROR ->> SCRIPT ERROR at runtime/errors/constant_dictionary_is_deep.gd:6 on test(): Invalid assignment on read-only value (on base: 'Array'). diff --git a/modules/gdscript/tests/scripts/runtime/errors/division_by_zero.gd b/modules/gdscript/tests/scripts/runtime/errors/division_by_zero.gd index ace5397f40a..e130576bc6a 100644 --- a/modules/gdscript/tests/scripts/runtime/errors/division_by_zero.gd +++ b/modules/gdscript/tests/scripts/runtime/errors/division_by_zero.gd @@ -1,3 +1,43 @@ +func subtest_int(): + var x: int = 1 + x /= 0 + print(x) + +func subtest_vector2i(): + var v: Vector2i = Vector2i.ONE + v /= Vector2i.ZERO + print(v) + +func subtest_vector3i(): + var v: Vector3i = Vector3i.ONE + v /= Vector3i.ZERO + print(v) + +func subtest_vector4i(): + var v: Vector4i = Vector4i.ONE + v /= Vector4i.ZERO + print(v) + +func subtest_vector2i_div_int(): + var v: Vector2i = Vector2i.ONE + v /= 0 + print(v) + +func subtest_vector3i_div_int(): + var v: Vector3i = Vector3i.ONE + v /= 0 + print(v) + +func subtest_vector4i_div_int(): + var v: Vector4i = Vector4i.ONE + v /= 0 + print(v) + func test(): - var integer: int = 1 - integer /= 0 + subtest_int() + subtest_vector2i() + subtest_vector3i() + subtest_vector4i() + subtest_vector2i_div_int() + subtest_vector3i_div_int() + subtest_vector4i_div_int() diff --git a/modules/gdscript/tests/scripts/runtime/errors/division_by_zero.out b/modules/gdscript/tests/scripts/runtime/errors/division_by_zero.out index 1175f0497d8..a3f65e71288 100644 --- a/modules/gdscript/tests/scripts/runtime/errors/division_by_zero.out +++ b/modules/gdscript/tests/scripts/runtime/errors/division_by_zero.out @@ -1,3 +1,8 @@ GDTEST_RUNTIME_ERROR -~~ WARNING at line 2: (UNUSED_VARIABLE) The local variable "integer" is declared but never used in the block. If this is intended, prefix it with an underscore: "_integer". ->> SCRIPT ERROR at runtime/errors/division_by_zero.gd:3 on test(): Division by zero error in operator '/'. +>> SCRIPT ERROR at runtime/errors/division_by_zero.gd:3 on subtest_int(): Division by zero error in operator '/'. +>> SCRIPT ERROR at runtime/errors/division_by_zero.gd:8 on subtest_vector2i(): Division by zero error in operator '/'. +>> SCRIPT ERROR at runtime/errors/division_by_zero.gd:13 on subtest_vector3i(): Division by zero error in operator '/'. +>> SCRIPT ERROR at runtime/errors/division_by_zero.gd:18 on subtest_vector4i(): Division by zero error in operator '/'. +>> SCRIPT ERROR at runtime/errors/division_by_zero.gd:23 on subtest_vector2i_div_int(): Division by zero error in operator '/'. +>> SCRIPT ERROR at runtime/errors/division_by_zero.gd:28 on subtest_vector3i_div_int(): Division by zero error in operator '/'. +>> SCRIPT ERROR at runtime/errors/division_by_zero.gd:33 on subtest_vector4i_div_int(): Division by zero error in operator '/'. diff --git a/modules/gdscript/tests/scripts/runtime/errors/gd_utility_function_wrong_arg.gd b/modules/gdscript/tests/scripts/runtime/errors/gd_utility_function_wrong_arg.gd deleted file mode 100644 index 340fc8c150b..00000000000 --- a/modules/gdscript/tests/scripts/runtime/errors/gd_utility_function_wrong_arg.gd +++ /dev/null @@ -1,3 +0,0 @@ -func test(): - var x = Color() - print(len(x)) # GDScript utility function. diff --git a/modules/gdscript/tests/scripts/runtime/errors/gd_utility_function_wrong_arg.out b/modules/gdscript/tests/scripts/runtime/errors/gd_utility_function_wrong_arg.out deleted file mode 100644 index ed58a05cce7..00000000000 --- a/modules/gdscript/tests/scripts/runtime/errors/gd_utility_function_wrong_arg.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_RUNTIME_ERROR ->> SCRIPT ERROR at runtime/errors/gd_utility_function_wrong_arg.gd:3 on test(): Error calling GDScript utility function "len()": Value of type 'Color' can't provide a length. diff --git a/modules/gdscript/tests/scripts/runtime/errors/invalid_cast.gd b/modules/gdscript/tests/scripts/runtime/errors/invalid_cast.gd new file mode 100644 index 00000000000..3bb55453988 --- /dev/null +++ b/modules/gdscript/tests/scripts/runtime/errors/invalid_cast.gd @@ -0,0 +1,22 @@ +func subtest_wrong_builtin(): + var integer: Variant = 1 + print(integer as Array) + +func subtest_builtin_as_object(): + var integer: Variant = 1 + print(integer as Node) + +func subtest_object_as_builtin(): + var object: Variant = RefCounted.new() + print(object as int) + +func subtest_freed_object(): + var node := Node.new() + node.free() + print(node as Node2D) + +func test(): + subtest_wrong_builtin() + subtest_builtin_as_object() + subtest_object_as_builtin() + subtest_freed_object() diff --git a/modules/gdscript/tests/scripts/runtime/errors/invalid_cast.out b/modules/gdscript/tests/scripts/runtime/errors/invalid_cast.out new file mode 100644 index 00000000000..5e0ccd54f44 --- /dev/null +++ b/modules/gdscript/tests/scripts/runtime/errors/invalid_cast.out @@ -0,0 +1,8 @@ +GDTEST_RUNTIME_ERROR +~~ WARNING at line 3: (UNSAFE_CAST) Casting "Variant" to "Array" is unsafe. +~~ WARNING at line 7: (UNSAFE_CAST) Casting "Variant" to "Node" is unsafe. +~~ WARNING at line 11: (UNSAFE_CAST) Casting "Variant" to "int" is unsafe. +>> SCRIPT ERROR at runtime/errors/invalid_cast.gd:3 on subtest_wrong_builtin(): Invalid cast: could not convert value to 'Array'. +>> SCRIPT ERROR at runtime/errors/invalid_cast.gd:7 on subtest_builtin_as_object(): Invalid cast: can't convert a non-object value to an object type. +>> SCRIPT ERROR at runtime/errors/invalid_cast.gd:11 on subtest_object_as_builtin(): Invalid cast: could not convert value to 'int'. +>> SCRIPT ERROR at runtime/errors/invalid_cast.gd:16 on subtest_freed_object(): Trying to cast a freed object. diff --git a/modules/gdscript/tests/scripts/runtime/errors/invalid_property_assignment.gd b/modules/gdscript/tests/scripts/runtime/errors/invalid_property_assignment.gd index 3724c8c7130..ed8b8a0cd80 100644 --- a/modules/gdscript/tests/scripts/runtime/errors/invalid_property_assignment.gd +++ b/modules/gdscript/tests/scripts/runtime/errors/invalid_property_assignment.gd @@ -1,9 +1,10 @@ # https://github.com/godotengine/godot/issues/90086 class MyObj: - var obj: WeakRef + var obj: WeakRef func test(): - var obj_1 = MyObj.new() - var obj_2 = MyObj.new() - obj_1.obj = obj_2 + var obj_1 = MyObj.new() + var obj_2 = MyObj.new() + obj_1.obj = obj_2 + prints(obj_1, obj_2) diff --git a/modules/gdscript/tests/scripts/runtime/errors/modulo_by_zero.gd b/modules/gdscript/tests/scripts/runtime/errors/modulo_by_zero.gd index 99792e4e326..b87c834b5c9 100644 --- a/modules/gdscript/tests/scripts/runtime/errors/modulo_by_zero.gd +++ b/modules/gdscript/tests/scripts/runtime/errors/modulo_by_zero.gd @@ -1,3 +1,43 @@ +func subtest_int(): + var x: int = 1 + x %= 0 + print(x) + +func subtest_vector2i(): + var v: Vector2i = Vector2i.ONE + v %= Vector2i.ZERO + print(v) + +func subtest_vector3i(): + var v: Vector3i = Vector3i.ONE + v %= Vector3i.ZERO + print(v) + +func subtest_vector4i(): + var v: Vector4i = Vector4i.ONE + v %= Vector4i.ZERO + print(v) + +func subtest_vector2i_mod_int(): + var v: Vector2i = Vector2i.ONE + v %= 0 + print(v) + +func subtest_vector3i_mod_int(): + var v: Vector3i = Vector3i.ONE + v %= 0 + print(v) + +func subtest_vector4i_mod_int(): + var v: Vector4i = Vector4i.ONE + v %= 0 + print(v) + func test(): - var integer: int = 1 - integer %= 0 + subtest_int() + subtest_vector2i() + subtest_vector3i() + subtest_vector4i() + subtest_vector2i_mod_int() + subtest_vector3i_mod_int() + subtest_vector4i_mod_int() diff --git a/modules/gdscript/tests/scripts/runtime/errors/modulo_by_zero.out b/modules/gdscript/tests/scripts/runtime/errors/modulo_by_zero.out index 6711735799a..21293d71449 100644 --- a/modules/gdscript/tests/scripts/runtime/errors/modulo_by_zero.out +++ b/modules/gdscript/tests/scripts/runtime/errors/modulo_by_zero.out @@ -1,3 +1,8 @@ GDTEST_RUNTIME_ERROR -~~ WARNING at line 2: (UNUSED_VARIABLE) The local variable "integer" is declared but never used in the block. If this is intended, prefix it with an underscore: "_integer". ->> SCRIPT ERROR at runtime/errors/modulo_by_zero.gd:3 on test(): Modulo by zero error in operator '%'. +>> SCRIPT ERROR at runtime/errors/modulo_by_zero.gd:3 on subtest_int(): Modulo by zero error in operator '%'. +>> SCRIPT ERROR at runtime/errors/modulo_by_zero.gd:8 on subtest_vector2i(): Modulo by zero error in operator '%'. +>> SCRIPT ERROR at runtime/errors/modulo_by_zero.gd:13 on subtest_vector3i(): Modulo by zero error in operator '%'. +>> SCRIPT ERROR at runtime/errors/modulo_by_zero.gd:18 on subtest_vector4i(): Modulo by zero error in operator '%'. +>> SCRIPT ERROR at runtime/errors/modulo_by_zero.gd:23 on subtest_vector2i_mod_int(): Modulo by zero error in operator '%'. +>> SCRIPT ERROR at runtime/errors/modulo_by_zero.gd:28 on subtest_vector3i_mod_int(): Modulo by zero error in operator '%'. +>> SCRIPT ERROR at runtime/errors/modulo_by_zero.gd:33 on subtest_vector4i_mod_int(): Modulo by zero error in operator '%'. diff --git a/modules/gdscript/tests/scripts/runtime/errors/non_static_method_call_on_native_class.gd b/modules/gdscript/tests/scripts/runtime/errors/non_static_method_call_on_native_class.gd index 0c15701364e..08b8e0c21bd 100644 --- a/modules/gdscript/tests/scripts/runtime/errors/non_static_method_call_on_native_class.gd +++ b/modules/gdscript/tests/scripts/runtime/errors/non_static_method_call_on_native_class.gd @@ -1,6 +1,7 @@ # https://github.com/godotengine/godot/issues/66675 -func test(): - example(Node2D) func example(thing): - print(thing.has_method('asdf')) + print(thing.has_method("asdf")) + +func test(): + example(Node2D) diff --git a/modules/gdscript/tests/scripts/runtime/errors/non_static_method_call_on_native_class.out b/modules/gdscript/tests/scripts/runtime/errors/non_static_method_call_on_native_class.out index fac0b4d8139..d1327d8785c 100644 --- a/modules/gdscript/tests/scripts/runtime/errors/non_static_method_call_on_native_class.out +++ b/modules/gdscript/tests/scripts/runtime/errors/non_static_method_call_on_native_class.out @@ -1,3 +1,3 @@ GDTEST_RUNTIME_ERROR -~~ WARNING at line 6: (UNSAFE_METHOD_ACCESS) The method "has_method()" is not present on the inferred type "Variant" (but may be present on a subtype). ->> SCRIPT ERROR at runtime/errors/non_static_method_call_on_native_class.gd:6 on example(): Invalid call. Nonexistent function 'has_method' in base 'Node2D'. +~~ WARNING at line 4: (UNSAFE_METHOD_ACCESS) The method "has_method()" is not present on the inferred type "Variant" (but may be present on a subtype). +>> SCRIPT ERROR at runtime/errors/non_static_method_call_on_native_class.gd:4 on example(): Invalid call. Nonexistent function 'has_method' in base 'Node2D'. diff --git a/modules/gdscript/tests/scripts/runtime/errors/read_only_dictionary.gd b/modules/gdscript/tests/scripts/runtime/errors/read_only_dictionary.gd deleted file mode 100644 index 2f31ecc52f0..00000000000 --- a/modules/gdscript/tests/scripts/runtime/errors/read_only_dictionary.gd +++ /dev/null @@ -1,4 +0,0 @@ -func test(): - var dictionary := { "a": 0 } - dictionary.make_read_only() - dictionary.a = 1 diff --git a/modules/gdscript/tests/scripts/runtime/errors/read_only_dictionary.out b/modules/gdscript/tests/scripts/runtime/errors/read_only_dictionary.out deleted file mode 100644 index 2c0247f3693..00000000000 --- a/modules/gdscript/tests/scripts/runtime/errors/read_only_dictionary.out +++ /dev/null @@ -1,4 +0,0 @@ -GDTEST_RUNTIME_ERROR ->> ERROR: Condition "_p->read_only" is true. Returning: false ->> Dictionary is in read-only state. ->> SCRIPT ERROR at runtime/errors/read_only_dictionary.gd:4 on test(): Invalid assignment on read-only value (on base: 'Dictionary'). diff --git a/modules/gdscript/tests/scripts/runtime/errors/typed_array.gd b/modules/gdscript/tests/scripts/runtime/errors/typed_array.gd new file mode 100644 index 00000000000..9ac45f017f5 --- /dev/null +++ b/modules/gdscript/tests/scripts/runtime/errors/typed_array.gd @@ -0,0 +1,37 @@ +class Foo: pass +class Bar extends Foo: pass +class Baz extends Foo: pass + +func expect_typed(typed: Array[int]): + print(typed.size()) + +func subtest_assign_basic_to_typed(): + var basic := [1] + var _typed: Array[int] = basic + print("end subtest_assign_basic_to_typed") + +func subtest_assign_basic_to_differently_typed(): + var differently: Variant = [1.0] as Array[float] + var _typed: Array[int] = differently + print("end subtest_assign_basic_to_differently_typed") + +func subtest_assign_wrong_to_typed(): + var _typed: Array[Bar] = [Baz.new() as Foo] + print("end subtest_assign_wrong_to_typed") + +func subtest_pass_basic_to_typed(): + var basic := [1] + expect_typed(basic) + print("end subtest_pass_basic_to_typed") + +func subtest_pass_basic_to_differently_typed(): + var differently: Variant = [1.0] as Array[float] + expect_typed(differently) + print("end subtest_pass_basic_to_differently_typed") + +func test(): + subtest_assign_basic_to_typed() + subtest_assign_basic_to_differently_typed() + subtest_assign_wrong_to_typed() + subtest_pass_basic_to_typed() + subtest_pass_basic_to_differently_typed() diff --git a/modules/gdscript/tests/scripts/runtime/errors/typed_array.out b/modules/gdscript/tests/scripts/runtime/errors/typed_array.out new file mode 100644 index 00000000000..28a000a63eb --- /dev/null +++ b/modules/gdscript/tests/scripts/runtime/errors/typed_array.out @@ -0,0 +1,10 @@ +GDTEST_RUNTIME_ERROR +~~ WARNING at line 29: (UNSAFE_CALL_ARGUMENT) The argument 1 of the function "expect_typed()" requires the subtype "Array[int]" but the supertype "Variant" was provided. +>> SCRIPT ERROR at runtime/errors/typed_array.gd:10 on subtest_assign_basic_to_typed(): Trying to assign an array of type "Array" to a variable of type "Array[int]". +>> SCRIPT ERROR at runtime/errors/typed_array.gd:15 on subtest_assign_basic_to_differently_typed(): Trying to assign an array of type "Array[float]" to a variable of type "Array[int]". +>> ERROR: Method/function failed. Returning: false +>> Attempted to set an object into a TypedArray, that does not inherit from 'GDScript'. +>> ERROR: Condition "!_p->typed.validate(value, "set")" is true. +end subtest_assign_wrong_to_typed +>> SCRIPT ERROR at runtime/errors/typed_array.gd:24 on subtest_pass_basic_to_typed(): Invalid type in function 'expect_typed' in base 'RefCounted (typed_array.gd)'. The array of argument 1 (Array) does not have the same element type as the expected typed array argument. +>> SCRIPT ERROR at runtime/errors/typed_array.gd:29 on subtest_pass_basic_to_differently_typed(): Invalid type in function 'expect_typed' in base 'RefCounted (typed_array.gd)'. The array of argument 1 (Array[float]) does not have the same element type as the expected typed array argument. diff --git a/modules/gdscript/tests/scripts/runtime/errors/typed_array_assign_basic_to_typed.gd b/modules/gdscript/tests/scripts/runtime/errors/typed_array_assign_basic_to_typed.gd deleted file mode 100644 index eedbef6fb80..00000000000 --- a/modules/gdscript/tests/scripts/runtime/errors/typed_array_assign_basic_to_typed.gd +++ /dev/null @@ -1,4 +0,0 @@ -func test(): - var basic := [1] - var _typed: Array[int] = basic - print('not ok') diff --git a/modules/gdscript/tests/scripts/runtime/errors/typed_array_assign_basic_to_typed.out b/modules/gdscript/tests/scripts/runtime/errors/typed_array_assign_basic_to_typed.out deleted file mode 100644 index 7f18f540002..00000000000 --- a/modules/gdscript/tests/scripts/runtime/errors/typed_array_assign_basic_to_typed.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_RUNTIME_ERROR ->> SCRIPT ERROR at runtime/errors/typed_array_assign_basic_to_typed.gd:3 on test(): Trying to assign an array of type "Array" to a variable of type "Array[int]". diff --git a/modules/gdscript/tests/scripts/runtime/errors/typed_array_assign_differently_typed.gd b/modules/gdscript/tests/scripts/runtime/errors/typed_array_assign_differently_typed.gd deleted file mode 100644 index c33e91bc810..00000000000 --- a/modules/gdscript/tests/scripts/runtime/errors/typed_array_assign_differently_typed.gd +++ /dev/null @@ -1,4 +0,0 @@ -func test(): - var differently: Variant = [1.0] as Array[float] - var _typed: Array[int] = differently - print('not ok') diff --git a/modules/gdscript/tests/scripts/runtime/errors/typed_array_assign_differently_typed.out b/modules/gdscript/tests/scripts/runtime/errors/typed_array_assign_differently_typed.out deleted file mode 100644 index 2ef0f716200..00000000000 --- a/modules/gdscript/tests/scripts/runtime/errors/typed_array_assign_differently_typed.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_RUNTIME_ERROR ->> SCRIPT ERROR at runtime/errors/typed_array_assign_differently_typed.gd:3 on test(): Trying to assign an array of type "Array[float]" to a variable of type "Array[int]". diff --git a/modules/gdscript/tests/scripts/runtime/errors/typed_array_assign_wrong_to_typed.gd b/modules/gdscript/tests/scripts/runtime/errors/typed_array_assign_wrong_to_typed.gd deleted file mode 100644 index 034fdd58dca..00000000000 --- a/modules/gdscript/tests/scripts/runtime/errors/typed_array_assign_wrong_to_typed.gd +++ /dev/null @@ -1,7 +0,0 @@ -class Foo: pass -class Bar extends Foo: pass -class Baz extends Foo: pass - -func test(): - var _typed: Array[Bar] = [Baz.new() as Foo] - print('not ok') diff --git a/modules/gdscript/tests/scripts/runtime/errors/typed_array_assign_wrong_to_typed.out b/modules/gdscript/tests/scripts/runtime/errors/typed_array_assign_wrong_to_typed.out deleted file mode 100644 index 2b4b64b092e..00000000000 --- a/modules/gdscript/tests/scripts/runtime/errors/typed_array_assign_wrong_to_typed.out +++ /dev/null @@ -1,5 +0,0 @@ -GDTEST_RUNTIME_ERROR ->> ERROR: Method/function failed. Returning: false ->> Attempted to set an object into a TypedArray, that does not inherit from 'GDScript'. ->> ERROR: Condition "!_p->typed.validate(value, "set")" is true. -not ok diff --git a/modules/gdscript/tests/scripts/runtime/errors/typed_array_pass_basic_to_typed.gd b/modules/gdscript/tests/scripts/runtime/errors/typed_array_pass_basic_to_typed.gd deleted file mode 100644 index e1fd0f71682..00000000000 --- a/modules/gdscript/tests/scripts/runtime/errors/typed_array_pass_basic_to_typed.gd +++ /dev/null @@ -1,7 +0,0 @@ -func expect_typed(typed: Array[int]): - print(typed.size()) - -func test(): - var basic := [1] - expect_typed(basic) - print('not ok') diff --git a/modules/gdscript/tests/scripts/runtime/errors/typed_array_pass_basic_to_typed.out b/modules/gdscript/tests/scripts/runtime/errors/typed_array_pass_basic_to_typed.out deleted file mode 100644 index fd052368a22..00000000000 --- a/modules/gdscript/tests/scripts/runtime/errors/typed_array_pass_basic_to_typed.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_RUNTIME_ERROR ->> SCRIPT ERROR at runtime/errors/typed_array_pass_basic_to_typed.gd:6 on test(): Invalid type in function 'expect_typed' in base 'RefCounted (typed_array_pass_basic_to_typed.gd)'. The array of argument 1 (Array) does not have the same element type as the expected typed array argument. diff --git a/modules/gdscript/tests/scripts/runtime/errors/typed_array_pass_differently_to_typed.gd b/modules/gdscript/tests/scripts/runtime/errors/typed_array_pass_differently_to_typed.gd deleted file mode 100644 index e2d2721e8c6..00000000000 --- a/modules/gdscript/tests/scripts/runtime/errors/typed_array_pass_differently_to_typed.gd +++ /dev/null @@ -1,7 +0,0 @@ -func expect_typed(typed: Array[int]): - print(typed.size()) - -func test(): - var differently: Variant = [1.0] as Array[float] - expect_typed(differently) - print('not ok') diff --git a/modules/gdscript/tests/scripts/runtime/errors/typed_array_pass_differently_to_typed.out b/modules/gdscript/tests/scripts/runtime/errors/typed_array_pass_differently_to_typed.out deleted file mode 100644 index 588b9fe2d6a..00000000000 --- a/modules/gdscript/tests/scripts/runtime/errors/typed_array_pass_differently_to_typed.out +++ /dev/null @@ -1,3 +0,0 @@ -GDTEST_RUNTIME_ERROR -~~ WARNING at line 6: (UNSAFE_CALL_ARGUMENT) The argument 1 of the function "expect_typed()" requires the subtype "Array[int]" but the supertype "Variant" was provided. ->> SCRIPT ERROR at runtime/errors/typed_array_pass_differently_to_typed.gd:6 on test(): Invalid type in function 'expect_typed' in base 'RefCounted (typed_array_pass_differently_to_typed.gd)'. The array of argument 1 (Array[float]) does not have the same element type as the expected typed array argument. diff --git a/modules/gdscript/tests/scripts/runtime/errors/typed_dictionary.gd b/modules/gdscript/tests/scripts/runtime/errors/typed_dictionary.gd new file mode 100644 index 00000000000..4a4496198c3 --- /dev/null +++ b/modules/gdscript/tests/scripts/runtime/errors/typed_dictionary.gd @@ -0,0 +1,55 @@ +class Foo: pass +class Bar extends Foo: pass +class Baz extends Foo: pass + +func get_key() -> Variant: + return "key" + +func get_value() -> Variant: + return "value" + +func expect_typed(typed: Dictionary[int, int]): + print(typed.size()) + +func subtest_assign_basic_to_typed(): + var basic := { 1: 1 } + var _typed: Dictionary[int, int] = basic + print("end subtest_assign_basic_to_typed") + +func subtest_assign_basic_to_differently_typed_key(): + var typed: Dictionary[int, int] + typed[get_key()] = 0 + print("end subtest_assign_basic_to_differently_typed_key") + +func subtest_assign_basic_to_differently_typed_value(): + var typed: Dictionary[int, int] + typed[0] = get_value() + print("end subtest_assign_basic_to_differently_typed_value") + +func subtest_assign_differently_typed(): + var differently: Variant = { 1.0: 0.0 } as Dictionary[float, float] + var _typed: Dictionary[int, int] = differently + print("end subtest_assign_differently_typed") + +func subtest_assign_wrong_to_typed(): + var _typed: Dictionary[Bar, Bar] = { Baz.new() as Foo: Baz.new() as Foo } + print("end subtest_assign_wrong_to_typed") + +func subtest_pass_basic_to_typed(): + var basic := { 1: 1 } + expect_typed(basic) + print("end subtest_pass_basic_to_typed") + +func subtest_pass_basic_to_differently_typed(): + var differently: Variant = { 1.0: 0.0 } as Dictionary[float, float] + expect_typed(differently) + print("end subtest_pass_basic_to_differently_typed") + +func test(): + subtest_assign_basic_to_typed() + subtest_assign_basic_to_differently_typed_key() + subtest_assign_basic_to_differently_typed_value() + subtest_assign_differently_typed() + subtest_assign_wrong_to_typed() + subtest_pass_basic_to_typed() + subtest_pass_basic_to_differently_typed() diff --git a/modules/gdscript/tests/scripts/runtime/errors/typed_dictionary.out b/modules/gdscript/tests/scripts/runtime/errors/typed_dictionary.out new file mode 100644 index 00000000000..4110f7fe541 --- /dev/null +++ b/modules/gdscript/tests/scripts/runtime/errors/typed_dictionary.out @@ -0,0 +1,18 @@ +GDTEST_RUNTIME_ERROR +~~ WARNING at line 45: (UNSAFE_CALL_ARGUMENT) The argument 1 of the function "expect_typed()" requires the subtype "Dictionary[int, int]" but the supertype "Variant" was provided. +>> SCRIPT ERROR at runtime/errors/typed_dictionary.gd:16 on subtest_assign_basic_to_typed(): Trying to assign a dictionary of type "Dictionary" to a variable of type "Dictionary[int, int]". +>> ERROR: Method/function failed. Returning: false +>> Attempted to set a variable of type 'String' into a TypedDictionary.Key of type 'int'. +>> ERROR: Condition "!_p->typed_key.validate(key, "set")" is true. Returning: false +>> SCRIPT ERROR at runtime/errors/typed_dictionary.gd:21 on subtest_assign_basic_to_differently_typed_key(): Invalid assignment of property or key 'key' with value of type 'int' on a base object of type 'Dictionary[int, int]'. +>> ERROR: Method/function failed. Returning: false +>> Attempted to set a variable of type 'String' into a TypedDictionary.Value of type 'int'. +>> ERROR: Condition "!_p->typed_value.validate(value, "set")" is true. Returning: false +>> SCRIPT ERROR at runtime/errors/typed_dictionary.gd:26 on subtest_assign_basic_to_differently_typed_value(): Invalid assignment of property or key '0' with value of type 'String' on a base object of type 'Dictionary[int, int]'. +>> SCRIPT ERROR at runtime/errors/typed_dictionary.gd:31 on subtest_assign_differently_typed(): Trying to assign a dictionary of type "Dictionary[float, float]" to a variable of type "Dictionary[int, int]". +>> ERROR: Method/function failed. Returning: false +>> Attempted to set an object into a TypedDictionary.Key, that does not inherit from 'GDScript'. +>> ERROR: Condition "!_p->typed_key.validate(key, "set")" is true. Returning: false +end subtest_assign_wrong_to_typed +>> SCRIPT ERROR at runtime/errors/typed_dictionary.gd:40 on subtest_pass_basic_to_typed(): Invalid type in function 'expect_typed' in base 'RefCounted (typed_dictionary.gd)'. The dictionary of argument 1 (Dictionary) does not have the same element type as the expected typed dictionary argument. +>> SCRIPT ERROR at runtime/errors/typed_dictionary.gd:45 on subtest_pass_basic_to_differently_typed(): Invalid type in function 'expect_typed' in base 'RefCounted (typed_dictionary.gd)'. The dictionary of argument 1 (Dictionary[float, float]) does not have the same element type as the expected typed dictionary argument. diff --git a/modules/gdscript/tests/scripts/runtime/errors/typed_dictionary_assign_basic_to_typed.gd b/modules/gdscript/tests/scripts/runtime/errors/typed_dictionary_assign_basic_to_typed.gd deleted file mode 100644 index 27cca0039b0..00000000000 --- a/modules/gdscript/tests/scripts/runtime/errors/typed_dictionary_assign_basic_to_typed.gd +++ /dev/null @@ -1,4 +0,0 @@ -func test(): - var basic := { 1: 1 } - var _typed: Dictionary[int, int] = basic - print('not ok') diff --git a/modules/gdscript/tests/scripts/runtime/errors/typed_dictionary_assign_basic_to_typed.out b/modules/gdscript/tests/scripts/runtime/errors/typed_dictionary_assign_basic_to_typed.out deleted file mode 100644 index 85775be31ae..00000000000 --- a/modules/gdscript/tests/scripts/runtime/errors/typed_dictionary_assign_basic_to_typed.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_RUNTIME_ERROR ->> SCRIPT ERROR at runtime/errors/typed_dictionary_assign_basic_to_typed.gd:3 on test(): Trying to assign a dictionary of type "Dictionary" to a variable of type "Dictionary[int, int]". diff --git a/modules/gdscript/tests/scripts/runtime/errors/typed_dictionary_assign_differently_typed.gd b/modules/gdscript/tests/scripts/runtime/errors/typed_dictionary_assign_differently_typed.gd deleted file mode 100644 index 04679696c03..00000000000 --- a/modules/gdscript/tests/scripts/runtime/errors/typed_dictionary_assign_differently_typed.gd +++ /dev/null @@ -1,4 +0,0 @@ -func test(): - var differently: Variant = { 1.0: 0.0 } as Dictionary[float, float] - var _typed: Dictionary[int, int] = differently - print('not ok') diff --git a/modules/gdscript/tests/scripts/runtime/errors/typed_dictionary_assign_differently_typed.out b/modules/gdscript/tests/scripts/runtime/errors/typed_dictionary_assign_differently_typed.out deleted file mode 100644 index 6215984b2c7..00000000000 --- a/modules/gdscript/tests/scripts/runtime/errors/typed_dictionary_assign_differently_typed.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_RUNTIME_ERROR ->> SCRIPT ERROR at runtime/errors/typed_dictionary_assign_differently_typed.gd:3 on test(): Trying to assign a dictionary of type "Dictionary[float, float]" to a variable of type "Dictionary[int, int]". diff --git a/modules/gdscript/tests/scripts/runtime/errors/typed_dictionary_assign_differently_typed_key.gd b/modules/gdscript/tests/scripts/runtime/errors/typed_dictionary_assign_differently_typed_key.gd deleted file mode 100644 index 2f0b3bd0ebf..00000000000 --- a/modules/gdscript/tests/scripts/runtime/errors/typed_dictionary_assign_differently_typed_key.gd +++ /dev/null @@ -1,7 +0,0 @@ -func get_key() -> Variant: - return "key" - -func test(): - var typed: Dictionary[int, int] - typed[get_key()] = 0 - print('not ok') diff --git a/modules/gdscript/tests/scripts/runtime/errors/typed_dictionary_assign_differently_typed_key.out b/modules/gdscript/tests/scripts/runtime/errors/typed_dictionary_assign_differently_typed_key.out deleted file mode 100644 index 58143a3693d..00000000000 --- a/modules/gdscript/tests/scripts/runtime/errors/typed_dictionary_assign_differently_typed_key.out +++ /dev/null @@ -1,5 +0,0 @@ -GDTEST_RUNTIME_ERROR ->> ERROR: Method/function failed. Returning: false ->> Attempted to set a variable of type 'String' into a TypedDictionary.Key of type 'int'. ->> ERROR: Condition "!_p->typed_key.validate(key, "set")" is true. Returning: false ->> SCRIPT ERROR at runtime/errors/typed_dictionary_assign_differently_typed_key.gd:6 on test(): Invalid assignment of property or key 'key' with value of type 'int' on a base object of type 'Dictionary[int, int]'. diff --git a/modules/gdscript/tests/scripts/runtime/errors/typed_dictionary_assign_differently_typed_value.gd b/modules/gdscript/tests/scripts/runtime/errors/typed_dictionary_assign_differently_typed_value.gd deleted file mode 100644 index b171159aedd..00000000000 --- a/modules/gdscript/tests/scripts/runtime/errors/typed_dictionary_assign_differently_typed_value.gd +++ /dev/null @@ -1,7 +0,0 @@ -func get_value() -> Variant: - return "value" - -func test(): - var typed: Dictionary[int, int] - typed[0] = get_value() - print("not ok") diff --git a/modules/gdscript/tests/scripts/runtime/errors/typed_dictionary_assign_differently_typed_value.out b/modules/gdscript/tests/scripts/runtime/errors/typed_dictionary_assign_differently_typed_value.out deleted file mode 100644 index 465ae7e15fa..00000000000 --- a/modules/gdscript/tests/scripts/runtime/errors/typed_dictionary_assign_differently_typed_value.out +++ /dev/null @@ -1,5 +0,0 @@ -GDTEST_RUNTIME_ERROR ->> ERROR: Method/function failed. Returning: false ->> Attempted to set a variable of type 'String' into a TypedDictionary.Value of type 'int'. ->> ERROR: Condition "!_p->typed_value.validate(value, "set")" is true. Returning: false ->> SCRIPT ERROR at runtime/errors/typed_dictionary_assign_differently_typed_value.gd:6 on test(): Invalid assignment of property or key '0' with value of type 'String' on a base object of type 'Dictionary[int, int]'. diff --git a/modules/gdscript/tests/scripts/runtime/errors/typed_dictionary_assign_wrong_to_typed.gd b/modules/gdscript/tests/scripts/runtime/errors/typed_dictionary_assign_wrong_to_typed.gd deleted file mode 100644 index 491d2e546a2..00000000000 --- a/modules/gdscript/tests/scripts/runtime/errors/typed_dictionary_assign_wrong_to_typed.gd +++ /dev/null @@ -1,7 +0,0 @@ -class Foo: pass -class Bar extends Foo: pass -class Baz extends Foo: pass - -func test(): - var _typed: Dictionary[Bar, Bar] = { Baz.new() as Foo: Baz.new() as Foo } - print('not ok') diff --git a/modules/gdscript/tests/scripts/runtime/errors/typed_dictionary_assign_wrong_to_typed.out b/modules/gdscript/tests/scripts/runtime/errors/typed_dictionary_assign_wrong_to_typed.out deleted file mode 100644 index 80a2cac1c6a..00000000000 --- a/modules/gdscript/tests/scripts/runtime/errors/typed_dictionary_assign_wrong_to_typed.out +++ /dev/null @@ -1,5 +0,0 @@ -GDTEST_RUNTIME_ERROR ->> ERROR: Method/function failed. Returning: false ->> Attempted to set an object into a TypedDictionary.Key, that does not inherit from 'GDScript'. ->> ERROR: Condition "!_p->typed_key.validate(key, "set")" is true. Returning: false -not ok diff --git a/modules/gdscript/tests/scripts/runtime/errors/typed_dictionary_pass_basic_to_typed.gd b/modules/gdscript/tests/scripts/runtime/errors/typed_dictionary_pass_basic_to_typed.gd deleted file mode 100644 index 8f7d7325843..00000000000 --- a/modules/gdscript/tests/scripts/runtime/errors/typed_dictionary_pass_basic_to_typed.gd +++ /dev/null @@ -1,7 +0,0 @@ -func expect_typed(typed: Dictionary[int, int]): - print(typed.size()) - -func test(): - var basic := { 1: 1 } - expect_typed(basic) - print('not ok') diff --git a/modules/gdscript/tests/scripts/runtime/errors/typed_dictionary_pass_basic_to_typed.out b/modules/gdscript/tests/scripts/runtime/errors/typed_dictionary_pass_basic_to_typed.out deleted file mode 100644 index 9d5ef04abd1..00000000000 --- a/modules/gdscript/tests/scripts/runtime/errors/typed_dictionary_pass_basic_to_typed.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_RUNTIME_ERROR ->> SCRIPT ERROR at runtime/errors/typed_dictionary_pass_basic_to_typed.gd:6 on test(): Invalid type in function 'expect_typed' in base 'RefCounted (typed_dictionary_pass_basic_to_typed.gd)'. The dictionary of argument 1 (Dictionary) does not have the same element type as the expected typed dictionary argument. diff --git a/modules/gdscript/tests/scripts/runtime/errors/typed_dictionary_pass_differently_to_typed.gd b/modules/gdscript/tests/scripts/runtime/errors/typed_dictionary_pass_differently_to_typed.gd deleted file mode 100644 index 978a9fdfeef..00000000000 --- a/modules/gdscript/tests/scripts/runtime/errors/typed_dictionary_pass_differently_to_typed.gd +++ /dev/null @@ -1,7 +0,0 @@ -func expect_typed(typed: Dictionary[int, int]): - print(typed.size()) - -func test(): - var differently: Variant = { 1.0: 0.0 } as Dictionary[float, float] - expect_typed(differently) - print('not ok') diff --git a/modules/gdscript/tests/scripts/runtime/errors/typed_dictionary_pass_differently_to_typed.out b/modules/gdscript/tests/scripts/runtime/errors/typed_dictionary_pass_differently_to_typed.out deleted file mode 100644 index 90d378d4c69..00000000000 --- a/modules/gdscript/tests/scripts/runtime/errors/typed_dictionary_pass_differently_to_typed.out +++ /dev/null @@ -1,3 +0,0 @@ -GDTEST_RUNTIME_ERROR -~~ WARNING at line 6: (UNSAFE_CALL_ARGUMENT) The argument 1 of the function "expect_typed()" requires the subtype "Dictionary[int, int]" but the supertype "Variant" was provided. ->> SCRIPT ERROR at runtime/errors/typed_dictionary_pass_differently_to_typed.gd:6 on test(): Invalid type in function 'expect_typed' in base 'RefCounted (typed_dictionary_pass_differently_to_typed.gd)'. The dictionary of argument 1 (Dictionary[float, float]) does not have the same element type as the expected typed dictionary argument. diff --git a/modules/gdscript/tests/scripts/runtime/errors/use_return_value_of_free_call.gd b/modules/gdscript/tests/scripts/runtime/errors/use_return_value_of_free_call.gd deleted file mode 100644 index a3daf70627e..00000000000 --- a/modules/gdscript/tests/scripts/runtime/errors/use_return_value_of_free_call.gd +++ /dev/null @@ -1,4 +0,0 @@ -func test(): - var obj - obj = Node.new() - print(obj.free()) diff --git a/modules/gdscript/tests/scripts/runtime/errors/use_return_value_of_free_call.out b/modules/gdscript/tests/scripts/runtime/errors/use_return_value_of_free_call.out deleted file mode 100644 index 45468f600c5..00000000000 --- a/modules/gdscript/tests/scripts/runtime/errors/use_return_value_of_free_call.out +++ /dev/null @@ -1,3 +0,0 @@ -GDTEST_RUNTIME_ERROR -~~ WARNING at line 4: (UNSAFE_METHOD_ACCESS) The method "free()" is not present on the inferred type "Variant" (but may be present on a subtype). ->> SCRIPT ERROR at runtime/errors/use_return_value_of_free_call.gd:4 on test(): Trying to get a return value of a method that returns "void" diff --git a/modules/gdscript/tests/scripts/runtime/errors/use_return_value_of_void_builtin_method_call.gd b/modules/gdscript/tests/scripts/runtime/errors/use_return_value_of_void_builtin_method_call.gd deleted file mode 100644 index 49fb76ad1ff..00000000000 --- a/modules/gdscript/tests/scripts/runtime/errors/use_return_value_of_void_builtin_method_call.gd +++ /dev/null @@ -1,4 +0,0 @@ -func test(): - var value - value = [] - print(value.reverse()) diff --git a/modules/gdscript/tests/scripts/runtime/errors/use_return_value_of_void_builtin_method_call.out b/modules/gdscript/tests/scripts/runtime/errors/use_return_value_of_void_builtin_method_call.out deleted file mode 100644 index dc1dd61d44e..00000000000 --- a/modules/gdscript/tests/scripts/runtime/errors/use_return_value_of_void_builtin_method_call.out +++ /dev/null @@ -1,3 +0,0 @@ -GDTEST_RUNTIME_ERROR -~~ WARNING at line 4: (UNSAFE_METHOD_ACCESS) The method "reverse()" is not present on the inferred type "Variant" (but may be present on a subtype). ->> SCRIPT ERROR at runtime/errors/use_return_value_of_void_builtin_method_call.gd:4 on test(): Trying to get a return value of a method that returns "void" diff --git a/modules/gdscript/tests/scripts/runtime/errors/use_return_value_of_void_native_method_call.gd b/modules/gdscript/tests/scripts/runtime/errors/use_return_value_of_void_native_method_call.gd deleted file mode 100644 index 44f9aa467a8..00000000000 --- a/modules/gdscript/tests/scripts/runtime/errors/use_return_value_of_void_native_method_call.gd +++ /dev/null @@ -1,4 +0,0 @@ -func test(): - var obj - obj = RefCounted.new() - print(obj.notify_property_list_changed()) diff --git a/modules/gdscript/tests/scripts/runtime/errors/use_return_value_of_void_native_method_call.out b/modules/gdscript/tests/scripts/runtime/errors/use_return_value_of_void_native_method_call.out deleted file mode 100644 index 93d9d1b82b0..00000000000 --- a/modules/gdscript/tests/scripts/runtime/errors/use_return_value_of_void_native_method_call.out +++ /dev/null @@ -1,3 +0,0 @@ -GDTEST_RUNTIME_ERROR -~~ WARNING at line 4: (UNSAFE_METHOD_ACCESS) The method "notify_property_list_changed()" is not present on the inferred type "Variant" (but may be present on a subtype). ->> SCRIPT ERROR at runtime/errors/use_return_value_of_void_native_method_call.gd:4 on test(): Trying to get a return value of a method that returns "void" diff --git a/modules/gdscript/tests/scripts/runtime/errors/use_value_of_void_function.gd b/modules/gdscript/tests/scripts/runtime/errors/use_value_of_void_function.gd new file mode 100644 index 00000000000..cd7c58cd155 --- /dev/null +++ b/modules/gdscript/tests/scripts/runtime/errors/use_value_of_void_function.gd @@ -0,0 +1,16 @@ +func subtest_builtin(): + var array: Variant = [] + print(array.reverse()) + +func subtest_native(): + var ref_counted: Variant = RefCounted.new() + print(ref_counted.notify_property_list_changed()) + +func subtest_free(): + var node: Variant = Node.new() + print(node.free()) + +func test(): + subtest_builtin() + subtest_native() + subtest_free() diff --git a/modules/gdscript/tests/scripts/runtime/errors/use_value_of_void_function.out b/modules/gdscript/tests/scripts/runtime/errors/use_value_of_void_function.out new file mode 100644 index 00000000000..281365b3d8f --- /dev/null +++ b/modules/gdscript/tests/scripts/runtime/errors/use_value_of_void_function.out @@ -0,0 +1,7 @@ +GDTEST_RUNTIME_ERROR +~~ WARNING at line 3: (UNSAFE_METHOD_ACCESS) The method "reverse()" is not present on the inferred type "Variant" (but may be present on a subtype). +~~ WARNING at line 7: (UNSAFE_METHOD_ACCESS) The method "notify_property_list_changed()" is not present on the inferred type "Variant" (but may be present on a subtype). +~~ WARNING at line 11: (UNSAFE_METHOD_ACCESS) The method "free()" is not present on the inferred type "Variant" (but may be present on a subtype). +>> SCRIPT ERROR at runtime/errors/use_value_of_void_function.gd:3 on subtest_builtin(): Trying to get a return value of a method that returns "void" +>> SCRIPT ERROR at runtime/errors/use_value_of_void_function.gd:7 on subtest_native(): Trying to get a return value of a method that returns "void" +>> SCRIPT ERROR at runtime/errors/use_value_of_void_function.gd:11 on subtest_free(): Trying to get a return value of a method that returns "void" diff --git a/modules/gdscript/tests/scripts/runtime/errors/utility_function_wrong_arg.gd b/modules/gdscript/tests/scripts/runtime/errors/utility_function_wrong_arg.gd deleted file mode 100644 index 6568155bae9..00000000000 --- a/modules/gdscript/tests/scripts/runtime/errors/utility_function_wrong_arg.gd +++ /dev/null @@ -1,3 +0,0 @@ -func test(): - var x = Color() - print(floor(x)) # Built-in utility function. diff --git a/modules/gdscript/tests/scripts/runtime/errors/utility_function_wrong_arg.out b/modules/gdscript/tests/scripts/runtime/errors/utility_function_wrong_arg.out deleted file mode 100644 index 5778d1bad45..00000000000 --- a/modules/gdscript/tests/scripts/runtime/errors/utility_function_wrong_arg.out +++ /dev/null @@ -1,2 +0,0 @@ -GDTEST_RUNTIME_ERROR ->> SCRIPT ERROR at runtime/errors/utility_function_wrong_arg.gd:3 on test(): Error calling utility function "floor()": Argument "x" must be "int", "float", "Vector2", "Vector2i", "Vector3", "Vector3i", "Vector4", or "Vector4i". diff --git a/modules/gdscript/tests/scripts/runtime/errors/utility_functions.gd b/modules/gdscript/tests/scripts/runtime/errors/utility_functions.gd new file mode 100644 index 00000000000..2bb3836920c --- /dev/null +++ b/modules/gdscript/tests/scripts/runtime/errors/utility_functions.gd @@ -0,0 +1,11 @@ +func subtest_pass_wrong_arg_builtin(): + var x = Color() + print(floor(x)) # Built-in utility function. + +func subtest_pass_wrong_arg_gdscript(): + var x = Color() + print(len(x)) # GDScript utility function. + +func test(): + subtest_pass_wrong_arg_builtin() + subtest_pass_wrong_arg_gdscript() diff --git a/modules/gdscript/tests/scripts/runtime/errors/utility_functions.out b/modules/gdscript/tests/scripts/runtime/errors/utility_functions.out new file mode 100644 index 00000000000..8eed200f673 --- /dev/null +++ b/modules/gdscript/tests/scripts/runtime/errors/utility_functions.out @@ -0,0 +1,3 @@ +GDTEST_RUNTIME_ERROR +>> SCRIPT ERROR at runtime/errors/utility_functions.gd:3 on subtest_pass_wrong_arg_builtin(): Error calling utility function "floor()": Argument "x" must be "int", "float", "Vector2", "Vector2i", "Vector3", "Vector3i", "Vector4", or "Vector4i". +>> SCRIPT ERROR at runtime/errors/utility_functions.gd:7 on subtest_pass_wrong_arg_gdscript(): Error calling GDScript utility function "len()": Value of type 'Color' can't provide a length. diff --git a/modules/gdscript/tests/scripts/runtime/features/argument_count.gd b/modules/gdscript/tests/scripts/runtime/features/argument_count.gd index 104489cfe60..88b83d3efd5 100644 --- a/modules/gdscript/tests/scripts/runtime/features/argument_count.gd +++ b/modules/gdscript/tests/scripts/runtime/features/argument_count.gd @@ -1,102 +1,102 @@ extends Node func my_func_1(_foo, _bar): - pass + pass func my_func_2(_foo, _bar, _baz): - pass + pass static func my_static_func_1(_foo, _bar): - pass + pass static func my_static_func_2(_foo, _bar, _baz): - pass + pass @rpc func my_rpc_func_1(_foo, _bar): - pass + pass @rpc func my_rpc_func_2(_foo, _bar, _baz): - pass + pass func test(): - # Test built-in methods. - var builtin_callable_1 : Callable = add_to_group - print(builtin_callable_1.get_argument_count()) # Should print 2. - var builtin_callable_2 : Callable = find_child - print(builtin_callable_2.get_argument_count()) # Should print 3. + # Test built-in methods. + var builtin_callable_1 : Callable = add_to_group + print(builtin_callable_1.get_argument_count()) # Should print 2. + var builtin_callable_2 : Callable = find_child + print(builtin_callable_2.get_argument_count()) # Should print 3. - # Test built-in vararg methods. - var builtin_vararg_callable_1 : Callable = call_thread_safe - print(builtin_vararg_callable_1.get_argument_count()) # Should print 1. - var builtin_vararg_callable_2 : Callable = rpc_id - print(builtin_vararg_callable_2.get_argument_count()) # Should print 2. + # Test built-in vararg methods. + var builtin_vararg_callable_1 : Callable = call_thread_safe + print(builtin_vararg_callable_1.get_argument_count()) # Should print 1. + var builtin_vararg_callable_2 : Callable = rpc_id + print(builtin_vararg_callable_2.get_argument_count()) # Should print 2. - # Test plain methods. - var callable_1 : Callable = my_func_1 - print(callable_1.get_argument_count()) # Should print 2. - var callable_2 : Callable = my_func_2 - print(callable_2.get_argument_count()) # Should print 3. + # Test plain methods. + var callable_1 : Callable = my_func_1 + print(callable_1.get_argument_count()) # Should print 2. + var callable_2 : Callable = my_func_2 + print(callable_2.get_argument_count()) # Should print 3. - # Test static methods. - var static_callable_1 : Callable = my_static_func_1 - print(static_callable_1.get_argument_count()) # Should print 2. - var static_callable_2 : Callable = my_static_func_2 - print(static_callable_2.get_argument_count()) # Should print 3. + # Test static methods. + var static_callable_1 : Callable = my_static_func_1 + print(static_callable_1.get_argument_count()) # Should print 2. + var static_callable_2 : Callable = my_static_func_2 + print(static_callable_2.get_argument_count()) # Should print 3. - # Test rpc methods. - var rpc_callable_1 : Callable = my_rpc_func_1 - print(rpc_callable_1.get_argument_count()) # Should print 2. - var rpc_callable_2 : Callable = my_rpc_func_2 - print(rpc_callable_2.get_argument_count()) # Should print 3. + # Test rpc methods. + var rpc_callable_1 : Callable = my_rpc_func_1 + print(rpc_callable_1.get_argument_count()) # Should print 2. + var rpc_callable_2 : Callable = my_rpc_func_2 + print(rpc_callable_2.get_argument_count()) # Should print 3. - # Test lambdas. - var lambda_callable_1 : Callable = func(_foo, _bar): pass - print(lambda_callable_1.get_argument_count()) # Should print 2. - var lambda_callable_2 : Callable = func(_foo, _bar, _baz): pass - print(lambda_callable_2.get_argument_count()) # Should print 3. + # Test lambdas. + var lambda_callable_1 : Callable = func(_foo, _bar): pass + print(lambda_callable_1.get_argument_count()) # Should print 2. + var lambda_callable_2 : Callable = func(_foo, _bar, _baz): pass + print(lambda_callable_2.get_argument_count()) # Should print 3. - # Test lambdas with self. - var lambda_self_callable_1 : Callable = func(_foo, _bar): return self - print(lambda_self_callable_1.get_argument_count()) # Should print 2. - var lambda_self_callable_2 : Callable = func(_foo, _bar, _baz): return self - print(lambda_self_callable_2.get_argument_count()) # Should print 3. + # Test lambdas with self. + var lambda_self_callable_1 : Callable = func(_foo, _bar): return self + print(lambda_self_callable_1.get_argument_count()) # Should print 2. + var lambda_self_callable_2 : Callable = func(_foo, _bar, _baz): return self + print(lambda_self_callable_2.get_argument_count()) # Should print 3. - # Test bind. - var bind_callable_1 : Callable = my_func_2.bind(1) - print(bind_callable_1.get_argument_count()) # Should print 2. - var bind_callable_2 : Callable = my_func_2.bind(1, 2) - print(bind_callable_2.get_argument_count()) # Should print 1. + # Test bind. + var bind_callable_1 : Callable = my_func_2.bind(1) + print(bind_callable_1.get_argument_count()) # Should print 2. + var bind_callable_2 : Callable = my_func_2.bind(1, 2) + print(bind_callable_2.get_argument_count()) # Should print 1. - # Test unbind. - var unbind_callable_1 : Callable = my_func_2.unbind(1) - print(unbind_callable_1.get_argument_count()) # Should print 4. - var unbind_callable_2 : Callable = my_func_2.unbind(2) - print(unbind_callable_2.get_argument_count()) # Should print 5. + # Test unbind. + var unbind_callable_1 : Callable = my_func_2.unbind(1) + print(unbind_callable_1.get_argument_count()) # Should print 4. + var unbind_callable_2 : Callable = my_func_2.unbind(2) + print(unbind_callable_2.get_argument_count()) # Should print 5. - # Test variant callables. - var string_tmp := String() - var variant_callable_1 : Callable = string_tmp.replace - print(variant_callable_1.get_argument_count()) # Should print 2. - var variant_callable_2 : Callable = string_tmp.rsplit - print(variant_callable_2.get_argument_count()) # Should print 3. + # Test variant callables. + var string_tmp := String() + var variant_callable_1 : Callable = string_tmp.replace + print(variant_callable_1.get_argument_count()) # Should print 2. + var variant_callable_2 : Callable = string_tmp.rsplit + print(variant_callable_2.get_argument_count()) # Should print 3. - # Test variant vararg callables. - var callable_tmp := Callable() - var variant_vararg_callable_1 : Callable = callable_tmp.call - print(variant_vararg_callable_1.get_argument_count()) # Should print 0. - var variant_vararg_callable_2 : Callable = callable_tmp.rpc_id - print(variant_vararg_callable_2.get_argument_count()) # Should print 1. + # Test variant vararg callables. + var callable_tmp := Callable() + var variant_vararg_callable_1 : Callable = callable_tmp.call + print(variant_vararg_callable_1.get_argument_count()) # Should print 0. + var variant_vararg_callable_2 : Callable = callable_tmp.rpc_id + print(variant_vararg_callable_2.get_argument_count()) # Should print 1. - # Test global methods. - var global_callable_1 = is_equal_approx - print(global_callable_1.get_argument_count()) # Should print 2. - var global_callable_2 = inverse_lerp - print(global_callable_2.get_argument_count()) # Should print 3. + # Test global methods. + var global_callable_1 = is_equal_approx + print(global_callable_1.get_argument_count()) # Should print 2. + var global_callable_2 = inverse_lerp + print(global_callable_2.get_argument_count()) # Should print 3. - # Test GDScript methods. - var gdscript_callable_1 = char - print(gdscript_callable_1.get_argument_count()) # Should print 1. - var gdscript_callable_2 = is_instance_of - print(gdscript_callable_2.get_argument_count()) # Should print 2. + # Test GDScript methods. + var gdscript_callable_1 = char + print(gdscript_callable_1.get_argument_count()) # Should print 1. + var gdscript_callable_2 = is_instance_of + print(gdscript_callable_2.get_argument_count()) # Should print 2. diff --git a/modules/gdscript/tests/scripts/runtime/features/const_class_reference.gd b/modules/gdscript/tests/scripts/runtime/features/const_class_reference.gd index c7553769dab..73fd8d549c6 100644 --- a/modules/gdscript/tests/scripts/runtime/features/const_class_reference.gd +++ b/modules/gdscript/tests/scripts/runtime/features/const_class_reference.gd @@ -3,8 +3,8 @@ const External := preload("const_class_reference_external.notest.gd") class Class1: - class Class2: - pass + class Class2: + pass const Class1Alias = Class1 const Class1Class2Alias = Class1.Class2 @@ -13,4 +13,4 @@ const ExternalAlias = External const ExternalClassAlias = External.Class func test(): - pass + pass diff --git a/modules/gdscript/tests/scripts/runtime/features/const_class_reference_external.notest.gd b/modules/gdscript/tests/scripts/runtime/features/const_class_reference_external.notest.gd index 050e8a09605..9aeb03143e5 100644 --- a/modules/gdscript/tests/scripts/runtime/features/const_class_reference_external.notest.gd +++ b/modules/gdscript/tests/scripts/runtime/features/const_class_reference_external.notest.gd @@ -1,2 +1,2 @@ class Class: - pass + pass diff --git a/modules/gdscript/tests/scripts/runtime/features/ctor_as_callable.gd b/modules/gdscript/tests/scripts/runtime/features/ctor_as_callable.gd index 515efbc9ce9..b8f45277d10 100644 --- a/modules/gdscript/tests/scripts/runtime/features/ctor_as_callable.gd +++ b/modules/gdscript/tests/scripts/runtime/features/ctor_as_callable.gd @@ -1,10 +1,10 @@ # https://github.com/godotengine/godot/issues/70319 class InnerClass: - pass + pass func test(): - var inner_ctor : Callable = InnerClass.new - print(inner_ctor) - var native_ctor : Callable = Node.new - print(native_ctor) + var inner_ctor : Callable = InnerClass.new + print(inner_ctor) + var native_ctor : Callable = Node.new + print(native_ctor) diff --git a/modules/gdscript/tests/scripts/runtime/features/export_group_no_name_conflict_with_properties.gd b/modules/gdscript/tests/scripts/runtime/features/export_group_no_name_conflict_with_properties.gd index 90df98e05bd..6becab18414 100644 --- a/modules/gdscript/tests/scripts/runtime/features/export_group_no_name_conflict_with_properties.gd +++ b/modules/gdscript/tests/scripts/runtime/features/export_group_no_name_conflict_with_properties.gd @@ -12,4 +12,4 @@ func test(): for property in get_property_list(): if str(property.name).begins_with("test_"): - Utils.print_property_extended_info(property, self) + print(Utils.get_property_extended_info(property, self)) diff --git a/modules/gdscript/tests/scripts/runtime/features/single_underscore_node_name.gd b/modules/gdscript/tests/scripts/runtime/features/single_underscore_node_name.gd index 11a670a7fb8..b30ab60a2ba 100644 --- a/modules/gdscript/tests/scripts/runtime/features/single_underscore_node_name.gd +++ b/modules/gdscript/tests/scripts/runtime/features/single_underscore_node_name.gd @@ -1,15 +1,15 @@ extends Node func test() -> void: - var node1 := Node.new() - node1.name = "_" - var node2 := Node.new() - node2.name = "Child" - var node3 := Node.new() - node3.name = "Child" + var node1 := Node.new() + node1.name = "_" + var node2 := Node.new() + node2.name = "Child" + var node3 := Node.new() + node3.name = "Child" - add_child(node1) - node1.add_child(node2) - add_child(node3) + add_child(node1) + node1.add_child(node2) + add_child(node3) - Utils.check(get_node("_/Child") == $_/Child) + Utils.check(get_node("_/Child") == $_/Child) diff --git a/modules/gdscript/tests/scripts/utils.notest.gd b/modules/gdscript/tests/scripts/utils.notest.gd index 1ae18631468..6ae89177f9b 100644 --- a/modules/gdscript/tests/scripts/utils.notest.gd +++ b/modules/gdscript/tests/scripts/utils.notest.gd @@ -74,53 +74,18 @@ static func get_property_signature( return result -static func get_human_readable_hint_string(property: Dictionary) -> String: - if property.type >= TYPE_ARRAY and property.hint == PROPERTY_HINT_TYPE_STRING: - var type_hint_prefixes: String = "" - var hint_string: String = property.hint_string - - while true: - if not hint_string.contains(":"): - printerr("Invalid PROPERTY_HINT_TYPE_STRING format.") - var elem_type_hint: String = hint_string.get_slice(":", 0) - hint_string = hint_string.substr(elem_type_hint.length() + 1) - - var elem_type: int - var elem_hint: int - - if elem_type_hint.is_valid_int(): - elem_type = elem_type_hint.to_int() - type_hint_prefixes += "<%s>:" % type_string(elem_type) - else: - if elem_type_hint.count("/") != 1: - printerr("Invalid PROPERTY_HINT_TYPE_STRING format.") - elem_type = elem_type_hint.get_slice("/", 0).to_int() - elem_hint = elem_type_hint.get_slice("/", 1).to_int() - type_hint_prefixes += "<%s>/<%s>:" % [ - type_string(elem_type), - get_property_hint_name(elem_hint).trim_prefix("PROPERTY_HINT_"), - ] - - if elem_type < TYPE_ARRAY or hint_string.is_empty(): - break - - return type_hint_prefixes + hint_string - - return property.hint_string - - -static func print_property_extended_info( +static func get_property_extended_info( property: Dictionary, base: Object = null, is_static: bool = false, -) -> void: - print(get_property_signature(property, base, is_static)) - print(' hint=%s hint_string="%s" usage=%s class_name=&"%s"' % [ +) -> String: + return '%s\n hint=%s hint_string="%s" usage=%s class_name=&"%s"' % [ + get_property_signature(property, base, is_static), get_property_hint_name(property.hint).trim_prefix("PROPERTY_HINT_"), - get_human_readable_hint_string(property).c_escape(), + get_property_hint_string(property).c_escape(), get_property_usage_string(property.usage).replace("PROPERTY_USAGE_", ""), str(property.class_name).c_escape(), - ]) + ] static func get_method_signature(method: Dictionary, is_signal: bool = false) -> String: @@ -237,13 +202,54 @@ static func get_property_hint_name(hint: PropertyHint) -> String: return "PROPERTY_HINT_PASSWORD" PROPERTY_HINT_TOOL_BUTTON: return "PROPERTY_HINT_TOOL_BUTTON" + PROPERTY_HINT_ONESHOT: + return "PROPERTY_HINT_ONESHOT" + PROPERTY_HINT_GROUP_ENABLE: + return "PROPERTY_HINT_GROUP_ENABLE" PROPERTY_HINT_INPUT_NAME: return "PROPERTY_HINT_INPUT_NAME" + PROPERTY_HINT_FILE_PATH: + return "PROPERTY_HINT_FILE_PATH" printerr("Argument `hint` is invalid. Use `PROPERTY_HINT_*` constants.") return "" +static func get_property_hint_string(property: Dictionary) -> String: + if property.type >= TYPE_ARRAY and property.hint == PROPERTY_HINT_TYPE_STRING: + var type_hint_prefixes: String = "" + var hint_string: String = property.hint_string + + while true: + if not hint_string.contains(":"): + printerr("Invalid `PROPERTY_HINT_TYPE_STRING` format.") + var elem_type_hint: String = hint_string.get_slice(":", 0) + hint_string = hint_string.substr(elem_type_hint.length() + 1) + + var elem_type: int + var elem_hint: int + + if elem_type_hint.is_valid_int(): + elem_type = elem_type_hint.to_int() + type_hint_prefixes += "<%s>:" % type_string(elem_type) + else: + if elem_type_hint.count("/") != 1: + printerr("Invalid `PROPERTY_HINT_TYPE_STRING` format.") + elem_type = elem_type_hint.get_slice("/", 0).to_int() + elem_hint = elem_type_hint.get_slice("/", 1).to_int() + type_hint_prefixes += "<%s>/<%s>:" % [ + type_string(elem_type), + get_property_hint_name(elem_hint).trim_prefix("PROPERTY_HINT_"), + ] + + if elem_type < TYPE_ARRAY or hint_string.is_empty(): + break + + return type_hint_prefixes + hint_string + + return property.hint_string + + static func get_property_usage_string(usage: int) -> String: if usage == PROPERTY_USAGE_NONE: return "PROPERTY_USAGE_NONE"