summaryrefslogtreecommitdiffstats
path: root/modules/gdscript/tests/scripts/runtime
diff options
context:
space:
mode:
authorDanil Alexeev <danil@alexeev.xyz>2024-05-22 10:07:31 +0300
committerDanil Alexeev <danil@alexeev.xyz>2024-05-22 10:07:31 +0300
commit4b692959de8a70edb0ccaef2289570e7fe7a8203 (patch)
tree7329c992d6bbaacabe2558adaf5e79546a1481bb /modules/gdscript/tests/scripts/runtime
parent214968243c442c0fdcbdfef23943c1547aeafdbc (diff)
downloadredot-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.gd26
-rw-r--r--modules/gdscript/tests/scripts/runtime/features/lambda_captures.out5
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