-
-
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
b00e1cb
commit aae9172
Showing
6 changed files
with
48 additions
and
9 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
16 changes: 16 additions & 0 deletions
16
modules/gdscript/tests/scripts/analyzer/warnings/local_variable_shadows_base_member.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,16 @@ | ||
class A: | ||
var foo1 | ||
|
||
func foo2(): | ||
pass | ||
|
||
class B extends A: | ||
func test1(foo1): | ||
return foo1 | ||
|
||
func test2(): | ||
var foo2 = 1 | ||
return foo2 | ||
|
||
func test(): | ||
pass |
9 changes: 9 additions & 0 deletions
9
modules/gdscript/tests/scripts/analyzer/warnings/local_variable_shadows_base_member.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,9 @@ | ||
GDTEST_OK | ||
>> WARNING | ||
>> Line: 8 | ||
>> SHADOWED_VARIABLE_BASE_CLASS | ||
>> The local function parameter "foo1" is shadowing an already-declared variable at line 2 in the base class "A". | ||
>> WARNING | ||
>> Line: 12 | ||
>> SHADOWED_VARIABLE_BASE_CLASS | ||
>> The local variable "foo2" is shadowing an already-declared function at line 4 in the base class "A". |