GDScript: Reset local variables on exit from block

This commit is contained in:
Danil Alexeev
2023-06-01 21:46:37 +03:00
parent 621d68e412
commit f3bf75fbb4
8 changed files with 96 additions and 14 deletions

View File

@@ -0,0 +1,10 @@
# GH-77666
func test():
var ref := RefCounted.new()
print(ref.get_reference_count())
if true:
var _temp := ref
print(ref.get_reference_count())

View File

@@ -0,0 +1,3 @@
GDTEST_OK
1
1

View File

@@ -0,0 +1,28 @@
# GH-56223, GH-76569
func test():
for i in 3:
var a
if true:
var b
if true:
var c
prints("Begin:", i, a, b, c)
a = 1
b = 1
c = 1
prints("End:", i, a, b, c)
print("===")
var j := 0
while j < 3:
var a
if true:
var b
if true:
var c
prints("Begin:", j, a, b, c)
a = 1
b = 1
c = 1
prints("End:", j, a, b, c)
j += 1

View File

@@ -0,0 +1,14 @@
GDTEST_OK
Begin: 0 <null> <null> <null>
End: 0 1 1 1
Begin: 1 <null> <null> <null>
End: 1 1 1 1
Begin: 2 <null> <null> <null>
End: 2 1 1 1
===
Begin: 0 <null> <null> <null>
End: 0 1 1 1
Begin: 1 <null> <null> <null>
End: 1 1 1 1
Begin: 2 <null> <null> <null>
End: 2 1 1 1