diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2023-08-21 19:26:32 +0200 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2023-08-21 19:26:32 +0200 |
commit | 7d3bee73e42b00a75bf9fafead8b200db994950c (patch) | |
tree | 48c4715000967030ee2ba31f65536047682ce5a4 /modules/gdscript/gdscript_warning.cpp | |
parent | 38b8751f0ddfdf5184135cf16770feafe09cd844 (diff) | |
parent | 6c59ed9485bbfadee73a08dfc57224e022626e6e (diff) | |
download | redot-engine-7d3bee73e42b00a75bf9fafead8b200db994950c.tar.gz |
Merge pull request #80247 from dalexeev/gds-for-loop-var-static-typing
GDScript: Add static typing for `for` loop variable
Diffstat (limited to 'modules/gdscript/gdscript_warning.cpp')
-rw-r--r-- | modules/gdscript/gdscript_warning.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/modules/gdscript/gdscript_warning.cpp b/modules/gdscript/gdscript_warning.cpp index 24aa793c47..4fec445995 100644 --- a/modules/gdscript/gdscript_warning.cpp +++ b/modules/gdscript/gdscript_warning.cpp @@ -113,6 +113,14 @@ 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: @@ -209,6 +217,7 @@ 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", |