GDScript: Fix bug with identifier shadowed below in current scope
This commit is contained in:
@ -0,0 +1,6 @@
|
||||
func test():
|
||||
if true:
|
||||
var a = 1
|
||||
print(a)
|
||||
var a = 2
|
||||
print(a)
|
||||
@ -0,0 +1,7 @@
|
||||
GDTEST_OK
|
||||
>> WARNING
|
||||
>> Line: 3
|
||||
>> CONFUSABLE_LOCAL_DECLARATION
|
||||
>> The variable "a" is declared below in the parent block.
|
||||
1
|
||||
2
|
||||
@ -0,0 +1,6 @@
|
||||
var a = 1
|
||||
|
||||
func test():
|
||||
print(a)
|
||||
var a = 2
|
||||
print(a)
|
||||
@ -0,0 +1,11 @@
|
||||
GDTEST_OK
|
||||
>> WARNING
|
||||
>> Line: 4
|
||||
>> CONFUSABLE_LOCAL_USAGE
|
||||
>> The identifier "a" will be shadowed below in the block.
|
||||
>> WARNING
|
||||
>> Line: 5
|
||||
>> SHADOWED_VARIABLE
|
||||
>> The local variable "a" is shadowing an already-declared variable at line 1.
|
||||
1
|
||||
2
|
||||
@ -0,0 +1,6 @@
|
||||
var a = 1
|
||||
|
||||
func test():
|
||||
print(a)
|
||||
var a = a + 1
|
||||
print(a)
|
||||
@ -0,0 +1,15 @@
|
||||
GDTEST_OK
|
||||
>> WARNING
|
||||
>> Line: 4
|
||||
>> CONFUSABLE_LOCAL_USAGE
|
||||
>> The identifier "a" will be shadowed below in the block.
|
||||
>> WARNING
|
||||
>> Line: 5
|
||||
>> CONFUSABLE_LOCAL_USAGE
|
||||
>> The identifier "a" will be shadowed below in the block.
|
||||
>> WARNING
|
||||
>> Line: 5
|
||||
>> SHADOWED_VARIABLE
|
||||
>> The local variable "a" is shadowing an already-declared variable at line 1.
|
||||
1
|
||||
2
|
||||
@ -0,0 +1,7 @@
|
||||
var a = 1
|
||||
|
||||
func test():
|
||||
for _i in 3:
|
||||
print(a)
|
||||
var a = 2
|
||||
print(a)
|
||||
@ -0,0 +1,15 @@
|
||||
GDTEST_OK
|
||||
>> WARNING
|
||||
>> Line: 5
|
||||
>> CONFUSABLE_LOCAL_USAGE
|
||||
>> The identifier "a" will be shadowed below in the block.
|
||||
>> WARNING
|
||||
>> Line: 6
|
||||
>> SHADOWED_VARIABLE
|
||||
>> The local variable "a" is shadowing an already-declared variable at line 1.
|
||||
1
|
||||
2
|
||||
1
|
||||
2
|
||||
1
|
||||
2
|
||||
Reference in New Issue
Block a user