mirror of
https://github.com/godotengine/godot.git
synced 2026-01-03 18:11:19 +03:00
Merge pull request #77744 from dalexeev/gds-reset-block-locals-on-exit
GDScript: Reset local variables on exit from block
This commit is contained in:
@@ -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())
|
||||
@@ -0,0 +1,3 @@
|
||||
GDTEST_OK
|
||||
1
|
||||
1
|
||||
@@ -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
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user