summaryrefslogtreecommitdiffstats
path: root/modules/gdscript/tests/scripts/analyzer/features
diff options
context:
space:
mode:
Diffstat (limited to 'modules/gdscript/tests/scripts/analyzer/features')
-rw-r--r--modules/gdscript/tests/scripts/analyzer/features/lambda_cyclic_ref_body.gd34
-rw-r--r--modules/gdscript/tests/scripts/analyzer/features/lambda_cyclic_ref_body.out5
2 files changed, 39 insertions, 0 deletions
diff --git a/modules/gdscript/tests/scripts/analyzer/features/lambda_cyclic_ref_body.gd b/modules/gdscript/tests/scripts/analyzer/features/lambda_cyclic_ref_body.gd
new file mode 100644
index 0000000000..e2f41a652c
--- /dev/null
+++ b/modules/gdscript/tests/scripts/analyzer/features/lambda_cyclic_ref_body.gd
@@ -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()
diff --git a/modules/gdscript/tests/scripts/analyzer/features/lambda_cyclic_ref_body.out b/modules/gdscript/tests/scripts/analyzer/features/lambda_cyclic_ref_body.out
new file mode 100644
index 0000000000..6917fa7c2c
--- /dev/null
+++ b/modules/gdscript/tests/scripts/analyzer/features/lambda_cyclic_ref_body.out
@@ -0,0 +1,5 @@
+GDTEST_OK
+1
+2
+3
+33