-
-
Notifications
You must be signed in to change notification settings - Fork 21.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix analyzer pushing SHADOWED_VARIABLE warning for members shadowed i…
…n subclasses This fixes a bug in the analyzer where it did not push the SHADOWED_VARIABLE_BASE_CLASS warning for members shadowed by variable in subclass. It does this by comparing the class which contains the shadowed member with the class containing the variable, and pushing SHADOWED_VARIABLE only if the classes are the same. Additionally, SHADOWED_VARIABLE_BASE_CLASS can take an extra symbol which helps to specify the line for non native base class.
- Loading branch information
1 parent
87318a2
commit 413490c
Showing
15 changed files
with
83 additions
and
42 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
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
7 changes: 7 additions & 0 deletions
7
modules/gdscript/tests/scripts/analyzer/warnings/shadowing_base.notest.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 @@ | ||
class_name ShadowingBase | ||
|
||
const base_const_member = 1 | ||
var base_variable_member | ||
|
||
func base_function_member(): | ||
pass |
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
32 changes: 22 additions & 10 deletions
32
modules/gdscript/tests/scripts/analyzer/warnings/shadowning.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,34 +1,46 @@ | ||
GDTEST_OK | ||
>> WARNING | ||
>> Line: 5 | ||
>> Line: 6 | ||
>> SHADOWED_GLOBAL_IDENTIFIER | ||
>> The variable "print_debug" has the same name as a built-in function. | ||
>> WARNING | ||
>> Line: 11 | ||
>> Line: 13 | ||
>> SHADOWED_GLOBAL_IDENTIFIER | ||
>> The variable "Array" has the same name as a built-in type. | ||
>> WARNING | ||
>> Line: 12 | ||
>> Line: 14 | ||
>> SHADOWED_GLOBAL_IDENTIFIER | ||
>> The variable "Node" has the same name as a native class. | ||
>> WARNING | ||
>> Line: 13 | ||
>> Line: 15 | ||
>> SHADOWED_GLOBAL_IDENTIFIER | ||
>> The variable "is_same" has the same name as a built-in function. | ||
>> WARNING | ||
>> Line: 14 | ||
>> Line: 16 | ||
>> SHADOWED_GLOBAL_IDENTIFIER | ||
>> The variable "sqrt" has the same name as a built-in function. | ||
>> WARNING | ||
>> Line: 15 | ||
>> Line: 17 | ||
>> SHADOWED_VARIABLE | ||
>> The local variable "member" is shadowing an already-declared variable at line 3. | ||
>> The local variable "member" is shadowing an already-declared variable at line 4 in the current class. | ||
>> WARNING | ||
>> Line: 16 | ||
>> Line: 18 | ||
>> SHADOWED_VARIABLE_BASE_CLASS | ||
>> The local variable "reference" is shadowing an already-declared method at the base class "RefCounted". | ||
>> The local variable "reference" is shadowing an already-declared method in the base class "RefCounted". | ||
>> WARNING | ||
>> Line: 17 | ||
>> Line: 19 | ||
>> SHADOWED_GLOBAL_IDENTIFIER | ||
>> The variable "ShadowedClass" has the same name as a global class defined in "shadowning.gd". | ||
>> WARNING | ||
>> Line: 20 | ||
>> SHADOWED_VARIABLE_BASE_CLASS | ||
>> The local variable "base_variable_member" is shadowing an already-declared variable at line 4 in the base class "ShadowingBase". | ||
>> WARNING | ||
>> Line: 21 | ||
>> SHADOWED_VARIABLE_BASE_CLASS | ||
>> The local constant "base_function_member" is shadowing an already-declared function at line 6 in the base class "ShadowingBase". | ||
>> WARNING | ||
>> Line: 22 | ||
>> SHADOWED_VARIABLE_BASE_CLASS | ||
>> The local variable "base_const_member" is shadowing an already-declared constant at line 3 in the base class "ShadowingBase". | ||
warn |
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