diff options
| author | George Marques <george@gmarqu.es> | 2024-04-12 11:49:21 -0300 |
|---|---|---|
| committer | George Marques <george@gmarqu.es> | 2024-04-12 11:49:21 -0300 |
| commit | 030995c10da93cbc0c3a3f00c73ee07948cbe543 (patch) | |
| tree | 540c9ced962de8da817e8ab95c2dcf8f4c6f90dc /modules/gdscript/tests/scripts | |
| parent | 30e71782afd9a1fd35707b89511bcd1aa538f673 (diff) | |
| download | redot-engine-030995c10da93cbc0c3a3f00c73ee07948cbe543.tar.gz | |
GDScript: Allow casting enum to int
An enum value is always an integer so the cast is valid. The code here
now consider this case to avoid giving an error message.
Diffstat (limited to 'modules/gdscript/tests/scripts')
| -rw-r--r-- | modules/gdscript/tests/scripts/analyzer/features/cast_enum_to_int.gd | 9 | ||||
| -rw-r--r-- | modules/gdscript/tests/scripts/analyzer/features/cast_enum_to_int.out | 2 |
2 files changed, 11 insertions, 0 deletions
diff --git a/modules/gdscript/tests/scripts/analyzer/features/cast_enum_to_int.gd b/modules/gdscript/tests/scripts/analyzer/features/cast_enum_to_int.gd new file mode 100644 index 0000000000..77ef9e2073 --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/features/cast_enum_to_int.gd @@ -0,0 +1,9 @@ +# GH-85882 + +enum Foo { A, B, C } + +func test(): + var a := Foo.A + var b := a as int + 1 + print(b) + diff --git a/modules/gdscript/tests/scripts/analyzer/features/cast_enum_to_int.out b/modules/gdscript/tests/scripts/analyzer/features/cast_enum_to_int.out new file mode 100644 index 0000000000..a7f1357bb2 --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/features/cast_enum_to_int.out @@ -0,0 +1,2 @@ +GDTEST_OK +1 |
