summaryrefslogtreecommitdiffstats
path: root/modules/gdscript/tests/scripts/analyzer/features/lambda_cyclic_ref_body.gd
blob: e2f41a652ceb1152a7f1275049e8953ee0fb9ea3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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()