summaryrefslogtreecommitdiffstats
path: root/modules/gdscript/gdscript_parser.cpp
diff options
context:
space:
mode:
authorZuBsPaCe <kurt.rudin@gmx.net>2021-09-10 22:08:02 +0200
committerZuBsPaCe <kurt.rudin@gmx.net>2021-09-10 22:26:50 +0200
commit1d1aa7a02fc64286a0c81cfb40fbf16f704d017e (patch)
tree9b3d348d42824fd7395831b5f413c6e75122136f /modules/gdscript/gdscript_parser.cpp
parent68563b57608ed50c2bf429770db75702598eb6bf (diff)
downloadredot-engine-1d1aa7a02fc64286a0c81cfb40fbf16f704d017e.tar.gz
GDScript: Removed spurious UNASSIGNED_VARIABLE warning for locals
Variable->assignment needs to be incremented when assigned a value. Also fixed and improved unit test 'variable_declaration.gd'. Fixes #52551
Diffstat (limited to 'modules/gdscript/gdscript_parser.cpp')
-rw-r--r--modules/gdscript/gdscript_parser.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/modules/gdscript/gdscript_parser.cpp b/modules/gdscript/gdscript_parser.cpp
index 6c3d4367e4..6ae3e36017 100644
--- a/modules/gdscript/gdscript_parser.cpp
+++ b/modules/gdscript/gdscript_parser.cpp
@@ -2369,8 +2369,12 @@ GDScriptParser::ExpressionNode *GDScriptParser::parse_assignment(ExpressionNode
}
#ifdef DEBUG_ENABLED
- if (has_operator && source_variable != nullptr && source_variable->assignments == 0) {
- push_warning(assignment, GDScriptWarning::UNASSIGNED_VARIABLE_OP_ASSIGN, source_variable->identifier->name);
+ if (source_variable != nullptr) {
+ if (has_operator && source_variable->assignments == 0) {
+ push_warning(assignment, GDScriptWarning::UNASSIGNED_VARIABLE_OP_ASSIGN, source_variable->identifier->name);
+ }
+
+ source_variable->assignments += 1;
}
#endif