forked from godotengine/godot
-
Notifications
You must be signed in to change notification settings - Fork 0
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 godotengine#93691 from dalexeev/gds-confusable-cap…
…ture-reassignment GDScript: Add `CONFUSABLE_CAPTURE_REASSIGNMENT` warning
- Loading branch information
Showing
7 changed files
with
88 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
27 changes: 27 additions & 0 deletions
27
modules/gdscript/tests/scripts/analyzer/warnings/confusable_capture_reassignment.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,27 @@ | ||
var member := 1 | ||
|
||
func test(): | ||
var number := 1 | ||
var string := "1" | ||
var vector := Vector2i(1, 0) | ||
var array_assign := [1] | ||
var array_append := [1] | ||
var f := func (): | ||
member = 2 | ||
number = 2 | ||
string += "2" | ||
vector.x = 2 | ||
array_assign = [2] | ||
array_append.append(2) | ||
var g := func (): | ||
member = 3 | ||
number = 3 | ||
string += "3" | ||
vector.x = 3 | ||
array_assign = [3] | ||
array_append.append(3) | ||
prints("g", member, number, string, vector, array_assign, array_append) | ||
g.call() | ||
prints("f", member, number, string, vector, array_assign, array_append) | ||
f.call() | ||
prints("test", member, number, string, vector, array_assign, array_append) |
36 changes: 36 additions & 0 deletions
36
modules/gdscript/tests/scripts/analyzer/warnings/confusable_capture_reassignment.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,36 @@ | ||
GDTEST_OK | ||
>> WARNING | ||
>> Line: 11 | ||
>> CONFUSABLE_CAPTURE_REASSIGNMENT | ||
>> Reassigning lambda capture does not modify the outer local variable "number". | ||
>> WARNING | ||
>> Line: 12 | ||
>> CONFUSABLE_CAPTURE_REASSIGNMENT | ||
>> Reassigning lambda capture does not modify the outer local variable "string". | ||
>> WARNING | ||
>> Line: 13 | ||
>> CONFUSABLE_CAPTURE_REASSIGNMENT | ||
>> Reassigning lambda capture does not modify the outer local variable "vector". | ||
>> WARNING | ||
>> Line: 14 | ||
>> CONFUSABLE_CAPTURE_REASSIGNMENT | ||
>> Reassigning lambda capture does not modify the outer local variable "array_assign". | ||
>> WARNING | ||
>> Line: 18 | ||
>> CONFUSABLE_CAPTURE_REASSIGNMENT | ||
>> Reassigning lambda capture does not modify the outer local variable "number". | ||
>> WARNING | ||
>> Line: 19 | ||
>> CONFUSABLE_CAPTURE_REASSIGNMENT | ||
>> Reassigning lambda capture does not modify the outer local variable "string". | ||
>> WARNING | ||
>> Line: 20 | ||
>> CONFUSABLE_CAPTURE_REASSIGNMENT | ||
>> Reassigning lambda capture does not modify the outer local variable "vector". | ||
>> WARNING | ||
>> Line: 21 | ||
>> CONFUSABLE_CAPTURE_REASSIGNMENT | ||
>> Reassigning lambda capture does not modify the outer local variable "array_assign". | ||
g 3 3 123 (3, 0) [3] [1, 2, 3] | ||
f 3 2 12 (2, 0) [2] [1, 2, 3] | ||
test 3 1 1 (1, 0) [1] [1, 2, 3] |
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