-
-
Notifications
You must be signed in to change notification settings - Fork 21.2k
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 #90756 from vnen/gdscript-warning-enum-without-def…
…ault GDScript: Warn when enum variable has no default
- Loading branch information
Showing
7 changed files
with
38 additions
and
0 deletions.
There are no files selected for viewing
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
9 changes: 9 additions & 0 deletions
9
modules/gdscript/tests/scripts/analyzer/warnings/enum_without_default_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,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) |
7 changes: 7 additions & 0 deletions
7
modules/gdscript/tests/scripts/analyzer/warnings/enum_without_default_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,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 |
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