-
-
Notifications
You must be signed in to change notification settings - Fork 21.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #94730 from dalexeev/gds-fix-while-locals-clearing
GDScript: Fix locals clearing after exiting `while` block
- Loading branch information
Showing
3 changed files
with
32 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 18 additions & 2 deletions
20
modules/gdscript/tests/scripts/runtime/features/reset_local_var_on_exit_block.gd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,26 @@ | ||
# GH-77666 | ||
|
||
func test(): | ||
func test_exit_if(): | ||
var ref := RefCounted.new() | ||
print(ref.get_reference_count()) | ||
|
||
if true: | ||
var _temp := ref | ||
|
||
print(ref.get_reference_count()) | ||
|
||
# GH-94654 | ||
func test_exit_while(): | ||
var slots_data := [] | ||
|
||
while true: | ||
@warning_ignore("confusable_local_declaration") | ||
var slot = 42 | ||
slots_data.append(slot) | ||
break | ||
|
||
var slot: int = slots_data[0] | ||
print(slot) | ||
|
||
func test(): | ||
test_exit_if() | ||
test_exit_while() |
1 change: 1 addition & 0 deletions
1
modules/gdscript/tests/scripts/runtime/features/reset_local_var_on_exit_block.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
GDTEST_OK | ||
1 | ||
1 | ||
42 |