GDScript: Fix lambda resolution with cyclic references
This commit is contained in:
parent
6758a7f8c0
commit
89429b0273
10 changed files with 127 additions and 31 deletions
|
|
@ -0,0 +1,5 @@
|
|||
var f = (func (_a): return 0).call(x)
|
||||
var x = f
|
||||
|
||||
func test():
|
||||
pass
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
GDTEST_ANALYZER_ERROR
|
||||
Could not resolve member "f": Cyclic reference.
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
var f = func (_a = x): return 0
|
||||
var x = f
|
||||
|
||||
func test():
|
||||
pass
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
GDTEST_ANALYZER_ERROR
|
||||
Could not resolve member "f": Cyclic reference.
|
||||
|
|
@ -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()
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
GDTEST_OK
|
||||
1
|
||||
2
|
||||
3
|
||||
33
|
||||
Loading…
Add table
Add a link
Reference in a new issue