GDScript: Warn when enum variable has no default
The default will always be set to `0`, so if it's not a valid value in the enum, the warning is shown.
This commit is contained in:
parent
658e97c93a
commit
f9048fcd7d
7 changed files with 38 additions and 0 deletions
|
|
@ -0,0 +1,9 @@
|
|||
enum HasZero { A = 0, B = 1 }
|
||||
enum HasNoZero { A = 1, B = 2 }
|
||||
var has_zero: HasZero # No warning, because the default `0` is valid.
|
||||
var has_no_zero: HasNoZero # Warning, because there is no `0` in the enum.
|
||||
|
||||
|
||||
func test():
|
||||
print(has_zero)
|
||||
print(has_no_zero)
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
GDTEST_OK
|
||||
>> WARNING
|
||||
>> Line: 4
|
||||
>> ENUM_VARIABLE_WITHOUT_DEFAULT
|
||||
>> The variable "has_no_zero" has an enum type and does not set an explicit default value. The default will be set to "0".
|
||||
0
|
||||
0
|
||||
Loading…
Add table
Add a link
Reference in a new issue