From ceda96013142080f9eb29be8dc7ca07db6030552 Mon Sep 17 00:00:00 2001 From: ryanabx Date: Tue, 5 Sep 2023 12:56:37 -0500 Subject: [PATCH] Remove REDUNDANT_FOR_VARIABLE_TYPE Remove REDUNDANT_FOR_VARIABLE_TYPE --- doc/classes/ProjectSettings.xml | 3 --- modules/gdscript/gdscript_analyzer.cpp | 8 -------- modules/gdscript/gdscript_warning.cpp | 9 --------- modules/gdscript/gdscript_warning.h | 2 -- .../for_loop_specified_type_is_equal_to_inferred.gd | 4 ---- .../for_loop_specified_type_is_equal_to_inferred.out | 5 ----- .../for_loop_specified_type_is_supertype_of_inferred.gd | 4 ---- .../for_loop_specified_type_is_supertype_of_inferred.out | 5 ----- 8 files changed, 40 deletions(-) delete mode 100644 modules/gdscript/tests/scripts/analyzer/warnings/for_loop_specified_type_is_equal_to_inferred.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/warnings/for_loop_specified_type_is_equal_to_inferred.out delete mode 100644 modules/gdscript/tests/scripts/analyzer/warnings/for_loop_specified_type_is_supertype_of_inferred.gd delete mode 100644 modules/gdscript/tests/scripts/analyzer/warnings/for_loop_specified_type_is_supertype_of_inferred.out diff --git a/doc/classes/ProjectSettings.xml b/doc/classes/ProjectSettings.xml index d3b124dcde5..1c8ab3870d1 100644 --- a/doc/classes/ProjectSettings.xml +++ b/doc/classes/ProjectSettings.xml @@ -492,9 +492,6 @@ When set to [code]warn[/code] or [code]error[/code], produces a warning or an error respectively when a function that is not a coroutine is called with await. - - When set to [code]warn[/code] or [code]error[/code], produces a warning or an error respectively when a [code]for[/code] variable type specifier is a supertype of the inferred type. - When set to [code]warn[/code] or [code]error[/code], produces a warning or an error respectively when the [code]@static_unload[/code] annotation is used in a script without any static variables. diff --git a/modules/gdscript/gdscript_analyzer.cpp b/modules/gdscript/gdscript_analyzer.cpp index 7b3d31f4a85..42be2314249 100644 --- a/modules/gdscript/gdscript_analyzer.cpp +++ b/modules/gdscript/gdscript_analyzer.cpp @@ -2142,15 +2142,7 @@ void GDScriptAnalyzer::resolve_for(GDScriptParser::ForNode *p_for) { } } else if (!is_type_compatible(specified_type, variable_type)) { p_for->use_conversion_assign = true; -#ifdef DEBUG_ENABLED - } else { - parser->push_warning(p_for->datatype_specifier, GDScriptWarning::REDUNDANT_FOR_VARIABLE_TYPE, p_for->variable->name, variable_type.to_string(), specified_type.to_string()); -#endif } -#ifdef DEBUG_ENABLED - } else if (variable_type.is_hard_type()) { - parser->push_warning(p_for->datatype_specifier, GDScriptWarning::REDUNDANT_FOR_VARIABLE_TYPE, p_for->variable->name, variable_type.to_string(), specified_type.to_string()); -#endif } p_for->variable->set_datatype(specified_type); } else { diff --git a/modules/gdscript/gdscript_warning.cpp b/modules/gdscript/gdscript_warning.cpp index fcc6ea34de9..ef2913926cb 100644 --- a/modules/gdscript/gdscript_warning.cpp +++ b/modules/gdscript/gdscript_warning.cpp @@ -119,14 +119,6 @@ String GDScriptWarning::get_message() const { return R"(The "@static_unload" annotation is redundant because the file does not have a class with static variables.)"; case REDUNDANT_AWAIT: return R"("await" keyword not needed in this case, because the expression isn't a coroutine nor a signal.)"; - case REDUNDANT_FOR_VARIABLE_TYPE: - CHECK_SYMBOLS(3); - if (symbols[1] == symbols[2]) { - return vformat(R"(The for loop iterator "%s" already has inferred type "%s", the specified type is redundant.)", symbols[0], symbols[1]); - } else { - return vformat(R"(The for loop iterator "%s" has inferred type "%s" but its supertype "%s" is specified.)", symbols[0], symbols[1], symbols[2]); - } - break; case ASSERT_ALWAYS_TRUE: return "Assert statement is redundant because the expression is always true."; case ASSERT_ALWAYS_FALSE: @@ -224,7 +216,6 @@ String GDScriptWarning::get_name_from_code(Code p_code) { "STATIC_CALLED_ON_INSTANCE", "REDUNDANT_STATIC_UNLOAD", "REDUNDANT_AWAIT", - "REDUNDANT_FOR_VARIABLE_TYPE", "ASSERT_ALWAYS_TRUE", "ASSERT_ALWAYS_FALSE", "INTEGER_DIVISION", diff --git a/modules/gdscript/gdscript_warning.h b/modules/gdscript/gdscript_warning.h index a26cfaf72ce..2b177093388 100644 --- a/modules/gdscript/gdscript_warning.h +++ b/modules/gdscript/gdscript_warning.h @@ -74,7 +74,6 @@ public: STATIC_CALLED_ON_INSTANCE, // A static method was called on an instance of a class instead of on the class itself. REDUNDANT_STATIC_UNLOAD, // The `@static_unload` annotation is used but the class does not have static data. REDUNDANT_AWAIT, // await is used but expression is synchronous (not a signal nor a coroutine). - REDUNDANT_FOR_VARIABLE_TYPE, // The for variable type specifier is a supertype of the inferred type. ASSERT_ALWAYS_TRUE, // Expression for assert argument is always true. ASSERT_ALWAYS_FALSE, // Expression for assert argument is always false. INTEGER_DIVISION, // Integer divide by integer, decimal part is discarded. @@ -123,7 +122,6 @@ public: WARN, // STATIC_CALLED_ON_INSTANCE WARN, // REDUNDANT_STATIC_UNLOAD WARN, // REDUNDANT_AWAIT - WARN, // REDUNDANT_FOR_VARIABLE_TYPE WARN, // ASSERT_ALWAYS_TRUE WARN, // ASSERT_ALWAYS_FALSE WARN, // INTEGER_DIVISION diff --git a/modules/gdscript/tests/scripts/analyzer/warnings/for_loop_specified_type_is_equal_to_inferred.gd b/modules/gdscript/tests/scripts/analyzer/warnings/for_loop_specified_type_is_equal_to_inferred.gd deleted file mode 100644 index 1b32491e48c..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/warnings/for_loop_specified_type_is_equal_to_inferred.gd +++ /dev/null @@ -1,4 +0,0 @@ -func test(): - var a: Array[Node] = [] - for node: Node in a: - print(node) diff --git a/modules/gdscript/tests/scripts/analyzer/warnings/for_loop_specified_type_is_equal_to_inferred.out b/modules/gdscript/tests/scripts/analyzer/warnings/for_loop_specified_type_is_equal_to_inferred.out deleted file mode 100644 index 3b3fbd9bd1b..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/warnings/for_loop_specified_type_is_equal_to_inferred.out +++ /dev/null @@ -1,5 +0,0 @@ -GDTEST_OK ->> WARNING ->> Line: 3 ->> REDUNDANT_FOR_VARIABLE_TYPE ->> The for loop iterator "node" already has inferred type "Node", the specified type is redundant. diff --git a/modules/gdscript/tests/scripts/analyzer/warnings/for_loop_specified_type_is_supertype_of_inferred.gd b/modules/gdscript/tests/scripts/analyzer/warnings/for_loop_specified_type_is_supertype_of_inferred.gd deleted file mode 100644 index fcbc13c53d0..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/warnings/for_loop_specified_type_is_supertype_of_inferred.gd +++ /dev/null @@ -1,4 +0,0 @@ -func test(): - var a: Array[Node2D] = [] - for node: Node in a: - print(node) diff --git a/modules/gdscript/tests/scripts/analyzer/warnings/for_loop_specified_type_is_supertype_of_inferred.out b/modules/gdscript/tests/scripts/analyzer/warnings/for_loop_specified_type_is_supertype_of_inferred.out deleted file mode 100644 index 36d4a161d39..00000000000 --- a/modules/gdscript/tests/scripts/analyzer/warnings/for_loop_specified_type_is_supertype_of_inferred.out +++ /dev/null @@ -1,5 +0,0 @@ -GDTEST_OK ->> WARNING ->> Line: 3 ->> REDUNDANT_FOR_VARIABLE_TYPE ->> The for loop iterator "node" has inferred type "Node2D" but its supertype "Node" is specified.