File: lambda_cyclic_ref_body.gd

package info (click to toggle)
godot 4.4.1%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 229,428 kB
  • sloc: cpp: 1,657,504; ansic: 186,969; xml: 153,923; cs: 36,104; java: 29,122; python: 15,230; javascript: 6,211; yacc: 4,115; pascal: 818; objc: 459; sh: 459; makefile: 109
file content (34 lines) | stat: -rw-r--r-- 552 bytes parent folder | download
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()