-
-
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.
Merge pull request #80923 from dalexeev/gds-fix-lambda-body-cyclic-re…
…f-resolution GDScript: Fix lambda resolution with cyclic references
- Loading branch information
Showing
10 changed files
with
127 additions
and
31 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
5 changes: 5 additions & 0 deletions
5
modules/gdscript/tests/scripts/analyzer/errors/lambda_cyclic_ref_call_arg.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,5 @@ | ||
var f = (func (_a): return 0).call(x) | ||
var x = f | ||
|
||
func test(): | ||
pass |
2 changes: 2 additions & 0 deletions
2
modules/gdscript/tests/scripts/analyzer/errors/lambda_cyclic_ref_call_arg.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,2 @@ | ||
GDTEST_ANALYZER_ERROR | ||
Could not resolve member "f": Cyclic reference. |
5 changes: 5 additions & 0 deletions
5
modules/gdscript/tests/scripts/analyzer/errors/lambda_cyclic_ref_param.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,5 @@ | ||
var f = func (_a = x): return 0 | ||
var x = f | ||
|
||
func test(): | ||
pass |
2 changes: 2 additions & 0 deletions
2
modules/gdscript/tests/scripts/analyzer/errors/lambda_cyclic_ref_param.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,2 @@ | ||
GDTEST_ANALYZER_ERROR | ||
Could not resolve member "f": Cyclic reference. |
34 changes: 34 additions & 0 deletions
34
modules/gdscript/tests/scripts/analyzer/features/lambda_cyclic_ref_body.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,34 @@ | ||
# GH-70592 | ||
|
||
var f: Callable = func (): | ||
x = 2 | ||
return 1 | ||
|
||
var x: int = f.call() | ||
|
||
var g: Array[Callable] = [ | ||
func (): | ||
y += 10 | ||
return 1, | ||
func (): | ||
y += 20 | ||
return 2, | ||
] | ||
|
||
var y: int = g[0].call() + g[1].call() | ||
|
||
func test(): | ||
print(x) | ||
f.call() | ||
print(x) | ||
|
||
print(y) | ||
g[0].call() | ||
g[1].call() | ||
print(y) | ||
|
||
# This prevents memory leak in CI. TODO: Investigate it. | ||
# Also you cannot run the `EditorScript` twice without the cleaning. Error: | ||
# Condition "!p_keep_state && has_instances" is true. Returning: ERR_ALREADY_IN_USE | ||
f = Callable() | ||
g.clear() |
5 changes: 5 additions & 0 deletions
5
modules/gdscript/tests/scripts/analyzer/features/lambda_cyclic_ref_body.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,5 @@ | ||
GDTEST_OK | ||
1 | ||
2 | ||
3 | ||
33 |