GDScript: Fix constant conversions

This commit is contained in:
Dmitrii Maganov
2023-01-22 10:32:05 +02:00
parent 218bef90af
commit 31e0ae2012
29 changed files with 204 additions and 105 deletions
@@ -0,0 +1,3 @@
func test():
var var_color: String = Color.RED
print('not ok')
@@ -0,0 +1,2 @@
GDTEST_ANALYZER_ERROR
Cannot assign a value of type "Color" as "String".
@@ -1,5 +0,0 @@
enum MyEnum { ENUM_VALUE_1, ENUM_VALUE_2 }
enum MyOtherEnum { OTHER_ENUM_VALUE_1, OTHER_ENUM_VALUE_2, OTHER_ENUM_VALUE_3 }
func test():
print(MyOtherEnum.OTHER_ENUM_VALUE_3 as MyEnum)
@@ -1,2 +0,0 @@
GDTEST_ANALYZER_ERROR
Invalid cast. Enum "cast_enum_bad_enum.gd::MyEnum" does not have value corresponding to "MyOtherEnum.OTHER_ENUM_VALUE_3" (2).
@@ -1,4 +0,0 @@
enum MyEnum { ENUM_VALUE_1, ENUM_VALUE_2 }
func test():
print(2 as MyEnum)
@@ -1,2 +0,0 @@
GDTEST_ANALYZER_ERROR
Invalid cast. Enum "cast_enum_bad_int.gd::MyEnum" does not have enum value 2.
@@ -1,2 +1,2 @@
GDTEST_ANALYZER_ERROR
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".
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".
@@ -1,2 +1,2 @@
GDTEST_ANALYZER_ERROR
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.
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".
@@ -1,2 +1,2 @@
GDTEST_ANALYZER_ERROR
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".
Cannot pass a value of type "enum_function_parameter_wrong_type.gd::MyOtherEnum" as "enum_function_parameter_wrong_type.gd::MyEnum".
@@ -1,2 +1,2 @@
GDTEST_ANALYZER_ERROR
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".
Cannot return a value of type "enum_function_return_wrong_type.gd::MyOtherEnum" as "enum_function_return_wrong_type.gd::MyEnum".
@@ -1,2 +1,2 @@
GDTEST_ANALYZER_ERROR
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".
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".
@@ -1,2 +1,2 @@
GDTEST_ANALYZER_ERROR
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".
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".
@@ -1,2 +1,2 @@
GDTEST_ANALYZER_ERROR
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.
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".
@@ -1,2 +1,2 @@
GDTEST_ANALYZER_ERROR
Value of type "enum_value_from_parent.gd::<anonymous enum>" cannot be assigned to a variable of type "enum_preload_unnamed_assign_to_named.gd::MyEnum".
Cannot assign a value of type "enum_value_from_parent.gd::<anonymous enum>" as "enum_preload_unnamed_assign_to_named.gd::MyEnum".
@@ -1,2 +1,2 @@
GDTEST_ANALYZER_ERROR
Cannot assign a value of type enum_unnamed_assign_to_named.gd::<anonymous enum> to variable "local_var" with specified type enum_unnamed_assign_to_named.gd::MyEnum.
Cannot assign a value of type "enum_unnamed_assign_to_named.gd::<anonymous enum>" as "enum_unnamed_assign_to_named.gd::MyEnum".
@@ -1,2 +1,2 @@
GDTEST_ANALYZER_ERROR
Cannot return value of type "String" because the function return type is "int".
Cannot return a value of type "String" as "int".
@@ -1,2 +1,2 @@
GDTEST_ANALYZER_ERROR
Value of type "enum_from_outer.gd::Named" cannot be assigned to a variable of type "preload_enum_error.gd::LocalNamed".
Cannot assign a value of type "enum_from_outer.gd::Named" as "preload_enum_error.gd::LocalNamed".