From 877802e2520e03593d2e5cf76cfa7659899b1aa4 Mon Sep 17 00:00:00 2001 From: George Marques Date: Tue, 9 Apr 2024 14:15:51 -0300 Subject: GDScript: Don't warn on unassigned for builtin-typed variables If the type of a variable is a built-in Variant type, then it will automatically be assigned a default value based on the type. This means that the explicit initialization may be unnecessary. Thus this commit removes the warning in such case. This also changes the meaning of the unassigned warning to happen when the variable is used before being assigned, not when it has zero assignments. --- .../scripts/runtime/features/reset_unassigned_variables_in_loops.gd | 2 ++ 1 file changed, 2 insertions(+) (limited to 'modules/gdscript/tests/scripts/runtime') diff --git a/modules/gdscript/tests/scripts/runtime/features/reset_unassigned_variables_in_loops.gd b/modules/gdscript/tests/scripts/runtime/features/reset_unassigned_variables_in_loops.gd index c45f8dce48..2bd5362f2a 100644 --- a/modules/gdscript/tests/scripts/runtime/features/reset_unassigned_variables_in_loops.gd +++ b/modules/gdscript/tests/scripts/runtime/features/reset_unassigned_variables_in_loops.gd @@ -7,6 +7,7 @@ func test(): var b if true: var c + @warning_ignore("unassigned_variable") prints("Begin:", i, a, b, c) a = 1 b = 1 @@ -20,6 +21,7 @@ func test(): var b if true: var c + @warning_ignore("unassigned_variable") prints("Begin:", j, a, b, c) a = 1 b = 1 -- cgit v1.2.3