1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-11 13:10:58 +00:00

Merge pull request #57591 from vnen/gdscript-enum-fixes

This commit is contained in:
Rémi Verschelde
2022-02-04 13:49:15 +01:00
committed by GitHub
34 changed files with 352 additions and 57 deletions

View File

@@ -0,0 +1,15 @@
enum MyEnum { ENUM_VALUE_1, ENUM_VALUE_2 }
# Assigning int value to enum-typed variable without explicit cast causes a warning.
# While it is valid it may be a mistake in the assignment.
var class_var: MyEnum = 0
func test():
print(class_var)
class_var = 1
print(class_var)
var local_var: MyEnum = 0
print(local_var)
local_var = 1
print(local_var)

View File

@@ -0,0 +1,21 @@
GDTEST_OK
>> WARNING
>> Line: 5
>> INT_ASSIGNED_TO_ENUM
>> Integer used when an enum value is expected. If this is intended cast the integer to the enum type.
>> WARNING
>> Line: 9
>> INT_ASSIGNED_TO_ENUM
>> Integer used when an enum value is expected. If this is intended cast the integer to the enum type.
>> WARNING
>> Line: 12
>> INT_ASSIGNED_TO_ENUM
>> Integer used when an enum value is expected. If this is intended cast the integer to the enum type.
>> WARNING
>> Line: 14
>> INT_ASSIGNED_TO_ENUM
>> Integer used when an enum value is expected. If this is intended cast the integer to the enum type.
0
1
0
1