diff options
| author | Danil Alexeev <danil@alexeev.xyz> | 2024-07-25 11:56:30 +0300 |
|---|---|---|
| committer | Danil Alexeev <danil@alexeev.xyz> | 2024-07-25 12:10:37 +0300 |
| commit | 5350e1beaa149725561fde8740e59eca7876394d (patch) | |
| tree | ee202c2816361a96128b63a14d6881eb38955a7b /modules/gdscript/tests/scripts | |
| parent | 91eb688e178fe32f28aebfbec01137abefd75413 (diff) | |
| download | redot-engine-5350e1beaa149725561fde8740e59eca7876394d.tar.gz | |
GDScript: Fix locals clearing after exiting `while` block
Diffstat (limited to 'modules/gdscript/tests/scripts')
| -rw-r--r-- | modules/gdscript/tests/scripts/runtime/features/reset_local_var_on_exit_block.gd | 20 | ||||
| -rw-r--r-- | modules/gdscript/tests/scripts/runtime/features/reset_local_var_on_exit_block.out | 1 |
2 files changed, 19 insertions, 2 deletions
diff --git a/modules/gdscript/tests/scripts/runtime/features/reset_local_var_on_exit_block.gd b/modules/gdscript/tests/scripts/runtime/features/reset_local_var_on_exit_block.gd index c774ebf83c..df639a7b4d 100644 --- a/modules/gdscript/tests/scripts/runtime/features/reset_local_var_on_exit_block.gd +++ b/modules/gdscript/tests/scripts/runtime/features/reset_local_var_on_exit_block.gd @@ -1,6 +1,5 @@ # GH-77666 - -func test(): +func test_exit_if(): var ref := RefCounted.new() print(ref.get_reference_count()) @@ -8,3 +7,20 @@ func test(): 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() diff --git a/modules/gdscript/tests/scripts/runtime/features/reset_local_var_on_exit_block.out b/modules/gdscript/tests/scripts/runtime/features/reset_local_var_on_exit_block.out index 04b4638adf..164eb24963 100644 --- a/modules/gdscript/tests/scripts/runtime/features/reset_local_var_on_exit_block.out +++ b/modules/gdscript/tests/scripts/runtime/features/reset_local_var_on_exit_block.out @@ -1,3 +1,4 @@ GDTEST_OK 1 1 +42 |
