-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
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 #92241 from dalexeev/gds-fix-lambda-captures-non-l…
…ocal-vars GDScript: Fix lambdas capturing non-local variables
- Loading branch information
Showing
3 changed files
with
48 additions
and
4 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
26 changes: 26 additions & 0 deletions
26
modules/gdscript/tests/scripts/runtime/features/lambda_captures.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,26 @@ | ||
# GH-92217 | ||
# TODO: Add more tests. | ||
|
||
static var static_var: int: | ||
set(value): | ||
prints("set static_var", value) | ||
get: | ||
print("get static_var") | ||
return 0 | ||
|
||
var member_var: int: | ||
set(value): | ||
prints("set member_var", value) | ||
get: | ||
print("get member_var") | ||
return 0 | ||
|
||
func test(): | ||
var lambda := func (): | ||
var _tmp := static_var | ||
_tmp = member_var | ||
|
||
static_var = 1 | ||
member_var = 1 | ||
|
||
lambda.call() |
5 changes: 5 additions & 0 deletions
5
modules/gdscript/tests/scripts/runtime/features/lambda_captures.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 | ||
get static_var | ||
get member_var | ||
set static_var 1 | ||
set member_var 1 |