-
-
Notifications
You must be signed in to change notification settings - Fork 21.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #69590 from anvilfolk/enums
GDScript enum fixes & refactor
- Loading branch information
Showing
61 changed files
with
698 additions
and
96 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
modules/gdscript/tests/scripts/analyzer/errors/assign_enum.gd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
enum { V } | ||
func test(): | ||
V = 1 |
2 changes: 2 additions & 0 deletions
2
modules/gdscript/tests/scripts/analyzer/errors/assign_enum.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
GDTEST_ANALYZER_ERROR | ||
Cannot assign a new value to a constant. |
3 changes: 3 additions & 0 deletions
3
modules/gdscript/tests/scripts/analyzer/errors/assign_named_enum.gd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
enum NamedEnum { V } | ||
func test(): | ||
NamedEnum.V = 1 |
2 changes: 2 additions & 0 deletions
2
modules/gdscript/tests/scripts/analyzer/errors/assign_named_enum.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
GDTEST_ANALYZER_ERROR | ||
Cannot assign a new value to a constant. |
5 changes: 5 additions & 0 deletions
5
modules/gdscript/tests/scripts/analyzer/errors/cast_enum_bad_enum.gd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
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) |
2 changes: 2 additions & 0 deletions
2
modules/gdscript/tests/scripts/analyzer/errors/cast_enum_bad_enum.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
GDTEST_ANALYZER_ERROR | ||
Invalid cast. Enum "cast_enum_bad_enum.gd::MyEnum" does not have value corresponding to "MyOtherEnum.OTHER_ENUM_VALUE_3" (2). |
4 changes: 4 additions & 0 deletions
4
modules/gdscript/tests/scripts/analyzer/errors/cast_enum_bad_int.gd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
enum MyEnum { ENUM_VALUE_1, ENUM_VALUE_2 } | ||
|
||
func test(): | ||
print(2 as MyEnum) |
2 changes: 2 additions & 0 deletions
2
modules/gdscript/tests/scripts/analyzer/errors/cast_enum_bad_int.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
GDTEST_ANALYZER_ERROR | ||
Invalid cast. Enum "cast_enum_bad_int.gd::MyEnum" does not have enum value 2. |
4 changes: 4 additions & 0 deletions
4
modules/gdscript/tests/scripts/analyzer/errors/enum_bad_method.gd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
enum Enum {V1, V2} | ||
|
||
func test(): | ||
Enum.clear() |
2 changes: 2 additions & 0 deletions
2
modules/gdscript/tests/scripts/analyzer/errors/enum_bad_method.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
GDTEST_ANALYZER_ERROR | ||
Cannot call non-const Dictionary function "clear()" on enum "Enum". |
4 changes: 4 additions & 0 deletions
4
modules/gdscript/tests/scripts/analyzer/errors/enum_bad_value.gd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
enum Enum {V1, V2} | ||
|
||
func test(): | ||
var bad = Enum.V3 |
2 changes: 2 additions & 0 deletions
2
modules/gdscript/tests/scripts/analyzer/errors/enum_bad_value.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
GDTEST_ANALYZER_ERROR | ||
Cannot find member "V3" in base "enum_bad_value.gd::Enum". |
2 changes: 1 addition & 1 deletion
2
...les/gdscript/tests/scripts/analyzer/errors/enum_class_var_assign_with_wrong_enum_type.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
GDTEST_ANALYZER_ERROR | ||
Cannot assign a value of type "MyOtherEnum (enum)" to a target of type "MyEnum (enum)". | ||
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". |
2 changes: 1 addition & 1 deletion
2
modules/gdscript/tests/scripts/analyzer/errors/enum_class_var_init_with_wrong_enum_type.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
GDTEST_ANALYZER_ERROR | ||
Cannot assign a value of type MyOtherEnum (enum) to variable "class_var" with specified type MyEnum (enum). | ||
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. |
5 changes: 5 additions & 0 deletions
5
modules/gdscript/tests/scripts/analyzer/errors/enum_duplicate_bad_method.gd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
enum Enum {V1, V2} | ||
|
||
func test(): | ||
var Enum2 = Enum | ||
Enum2.clear() |
2 changes: 2 additions & 0 deletions
2
modules/gdscript/tests/scripts/analyzer/errors/enum_duplicate_bad_method.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
GDTEST_ANALYZER_ERROR | ||
Cannot call non-const Dictionary function "clear()" on enum "Enum". |
8 changes: 8 additions & 0 deletions
8
modules/gdscript/tests/scripts/analyzer/errors/enum_function_parameter_wrong_type.gd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
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) |
2 changes: 2 additions & 0 deletions
2
modules/gdscript/tests/scripts/analyzer/errors/enum_function_parameter_wrong_type.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +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". |
8 changes: 8 additions & 0 deletions
8
modules/gdscript/tests/scripts/analyzer/errors/enum_function_return_wrong_type.gd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
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()) |
2 changes: 2 additions & 0 deletions
2
modules/gdscript/tests/scripts/analyzer/errors/enum_function_return_wrong_type.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +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". |
10 changes: 10 additions & 0 deletions
10
...dscript/tests/scripts/analyzer/errors/enum_local_var_assign_outer_with_wrong_enum_type.gd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
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) |
2 changes: 2 additions & 0 deletions
2
...script/tests/scripts/analyzer/errors/enum_local_var_assign_outer_with_wrong_enum_type.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +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". |
2 changes: 1 addition & 1 deletion
2
...les/gdscript/tests/scripts/analyzer/errors/enum_local_var_assign_with_wrong_enum_type.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
GDTEST_ANALYZER_ERROR | ||
Cannot assign a value of type "MyOtherEnum (enum)" to a target of type "MyEnum (enum)". | ||
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". |
2 changes: 1 addition & 1 deletion
2
modules/gdscript/tests/scripts/analyzer/errors/enum_local_var_init_with_wrong_enum_type.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
GDTEST_ANALYZER_ERROR | ||
Cannot assign a value of type MyOtherEnum (enum) to variable "local_var" with specified type MyEnum (enum). | ||
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. |
2 changes: 2 additions & 0 deletions
2
modules/gdscript/tests/scripts/analyzer/errors/enum_native_bad_value.gd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
func test(): | ||
var _bad = TileSet.TileShape.THIS_DOES_NOT_EXIST |
2 changes: 2 additions & 0 deletions
2
modules/gdscript/tests/scripts/analyzer/errors/enum_native_bad_value.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
GDTEST_ANALYZER_ERROR | ||
Cannot find member "THIS_DOES_NOT_EXIST" in base "TileSet::TileShape". |
6 changes: 6 additions & 0 deletions
6
modules/gdscript/tests/scripts/analyzer/errors/enum_preload_unnamed_assign_to_named.gd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
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) |
2 changes: 2 additions & 0 deletions
2
modules/gdscript/tests/scripts/analyzer/errors/enum_preload_unnamed_assign_to_named.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +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". |
8 changes: 8 additions & 0 deletions
8
modules/gdscript/tests/scripts/analyzer/errors/enum_shadows_base_enum.gd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
class A: | ||
enum { V } | ||
|
||
class B extends A: | ||
enum { V } | ||
|
||
func test(): | ||
pass |
2 changes: 2 additions & 0 deletions
2
modules/gdscript/tests/scripts/analyzer/errors/enum_shadows_base_enum.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
GDTEST_ANALYZER_ERROR | ||
The member "V" already exists in parent class A. |
7 changes: 7 additions & 0 deletions
7
modules/gdscript/tests/scripts/analyzer/errors/enum_shadows_outer_enum.gd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
enum { V } | ||
|
||
class InnerClass: | ||
enum { V } | ||
|
||
func test(): | ||
pass |
2 changes: 2 additions & 0 deletions
2
modules/gdscript/tests/scripts/analyzer/errors/enum_shadows_outer_enum.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
GDTEST_PARSER_ERROR | ||
Name "V" is already used as a class enum value. |
7 changes: 7 additions & 0 deletions
7
modules/gdscript/tests/scripts/analyzer/errors/enum_unnamed_assign_to_named.gd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
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) |
2 changes: 2 additions & 0 deletions
2
modules/gdscript/tests/scripts/analyzer/errors/enum_unnamed_assign_to_named.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +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. |
2 changes: 2 additions & 0 deletions
2
modules/gdscript/tests/scripts/analyzer/errors/native_type_errors.gd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
func test(): | ||
TileSet.this_does_not_exist # Does not exist |
2 changes: 2 additions & 0 deletions
2
modules/gdscript/tests/scripts/analyzer/errors/native_type_errors.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
GDTEST_ANALYZER_ERROR | ||
Cannot find member "this_does_not_exist" in base "TileSet". |
6 changes: 6 additions & 0 deletions
6
modules/gdscript/tests/scripts/analyzer/errors/preload_enum_error.gd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
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 |
2 changes: 2 additions & 0 deletions
2
modules/gdscript/tests/scripts/analyzer/errors/preload_enum_error.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +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". |
2 changes: 1 addition & 1 deletion
2
modules/gdscript/tests/scripts/analyzer/errors/property_inline_set_type_error.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
GDTEST_ANALYZER_ERROR | ||
Cannot assign a value of type "String" to a target of type "int". | ||
Value of type "String" cannot be assigned to a variable of type "int". |
29 changes: 29 additions & 0 deletions
29
modules/gdscript/tests/scripts/analyzer/features/enum_access_types.gd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
class_name EnumAccessOuterClass | ||
|
||
class InnerClass: | ||
enum MyEnum { V0, V2, V1 } | ||
|
||
static func print_enums(): | ||
print("Inner - Inner") | ||
print(MyEnum.V0, MyEnum.V1, MyEnum.V2) | ||
print(InnerClass.MyEnum.V0, InnerClass.MyEnum.V1, InnerClass.MyEnum.V2) | ||
print(EnumAccessOuterClass.InnerClass.MyEnum.V0, EnumAccessOuterClass.InnerClass.MyEnum.V1, EnumAccessOuterClass.InnerClass.MyEnum.V2) | ||
|
||
print("Inner - Outer") | ||
print(EnumAccessOuterClass.MyEnum.V0, EnumAccessOuterClass.MyEnum.V1, EnumAccessOuterClass.MyEnum.V2) | ||
|
||
|
||
enum MyEnum { V0, V1, V2 } | ||
|
||
func print_enums(): | ||
print("Outer - Outer") | ||
print(MyEnum.V0, MyEnum.V1, MyEnum.V2) | ||
print(EnumAccessOuterClass.MyEnum.V0, EnumAccessOuterClass.MyEnum.V1, EnumAccessOuterClass.MyEnum.V2) | ||
|
||
print("Outer - Inner") | ||
print(InnerClass.MyEnum.V0, InnerClass.MyEnum.V1, InnerClass.MyEnum.V2) | ||
print(EnumAccessOuterClass.InnerClass.MyEnum.V0, EnumAccessOuterClass.InnerClass.MyEnum.V1, EnumAccessOuterClass.InnerClass.MyEnum.V2) | ||
|
||
func test(): | ||
print_enums() | ||
InnerClass.print_enums() |
13 changes: 13 additions & 0 deletions
13
modules/gdscript/tests/scripts/analyzer/features/enum_access_types.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
GDTEST_OK | ||
Outer - Outer | ||
012 | ||
012 | ||
Outer - Inner | ||
021 | ||
021 | ||
Inner - Inner | ||
021 | ||
021 | ||
021 | ||
Inner - Outer | ||
012 |
13 changes: 13 additions & 0 deletions
13
modules/gdscript/tests/scripts/analyzer/features/enum_duplicate_into_dict.gd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
enum Enum {V1, V2} | ||
|
||
func test(): | ||
var enumAsDict : Dictionary = Enum.duplicate() | ||
var enumAsVariant = Enum.duplicate() | ||
print(Enum.has("V1")) | ||
print(enumAsDict.has("V1")) | ||
print(enumAsVariant.has("V1")) | ||
enumAsDict.clear() | ||
enumAsVariant.clear() | ||
print(Enum.has("V1")) | ||
print(enumAsDict.has("V1")) | ||
print(enumAsVariant.has("V1")) |
7 changes: 7 additions & 0 deletions
7
modules/gdscript/tests/scripts/analyzer/features/enum_duplicate_into_dict.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
GDTEST_OK | ||
true | ||
true | ||
true | ||
true | ||
false | ||
false |
Oops, something went wrong.