diff options
author | Danil Alexeev <danil@alexeev.xyz> | 2024-05-22 10:07:31 +0300 |
---|---|---|
committer | Danil Alexeev <danil@alexeev.xyz> | 2024-05-22 10:07:31 +0300 |
commit | 4b692959de8a70edb0ccaef2289570e7fe7a8203 (patch) | |
tree | 7329c992d6bbaacabe2558adaf5e79546a1481bb /modules/gdscript/tests/scripts/runtime | |
parent | 214968243c442c0fdcbdfef23943c1547aeafdbc (diff) | |
download | redot-engine-4b692959de8a70edb0ccaef2289570e7fe7a8203.tar.gz |
GDScript: Fix lambdas capturing non-local variables
Diffstat (limited to 'modules/gdscript/tests/scripts/runtime')
-rw-r--r-- | modules/gdscript/tests/scripts/runtime/features/lambda_captures.gd | 26 | ||||
-rw-r--r-- | modules/gdscript/tests/scripts/runtime/features/lambda_captures.out | 5 |
2 files changed, 31 insertions, 0 deletions
diff --git a/modules/gdscript/tests/scripts/runtime/features/lambda_captures.gd b/modules/gdscript/tests/scripts/runtime/features/lambda_captures.gd new file mode 100644 index 0000000000..bbdf745540 --- /dev/null +++ b/modules/gdscript/tests/scripts/runtime/features/lambda_captures.gd @@ -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() diff --git a/modules/gdscript/tests/scripts/runtime/features/lambda_captures.out b/modules/gdscript/tests/scripts/runtime/features/lambda_captures.out new file mode 100644 index 0000000000..0bdf74a43f --- /dev/null +++ b/modules/gdscript/tests/scripts/runtime/features/lambda_captures.out @@ -0,0 +1,5 @@ +GDTEST_OK +get static_var +get member_var +set static_var 1 +set member_var 1 |