diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2020-05-14 16:48:56 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-14 16:48:56 +0200 |
commit | 963a27f8a2a2d05bd6ed9a3b3673702622179821 (patch) | |
tree | d1181f817a9512d3f1b6e3d3a34d594a7adc3bcd /modules | |
parent | 27b4915fa8aaa3b60386105a2c8f3ae62bf21a9a (diff) | |
parent | 79eee93b9a24b377a57ca034b21ea30fbf91eead (diff) |
Merge pull request #38611 from ThakeeNathees/shadow-var-warning-bug-fix
shadowed var warning in nested block bug fix
Diffstat (limited to 'modules')
-rw-r--r-- | modules/gdscript/gdscript_parser.cpp | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/modules/gdscript/gdscript_parser.cpp b/modules/gdscript/gdscript_parser.cpp index b900ba903f..8cc6986f34 100644 --- a/modules/gdscript/gdscript_parser.cpp +++ b/modules/gdscript/gdscript_parser.cpp @@ -8228,17 +8228,6 @@ void GDScriptParser::_check_function_types(FunctionNode *p_function) { p_function->return_type.has_type = false; p_function->return_type.may_yield = true; } - -#ifdef DEBUG_ENABLED - for (Map<StringName, LocalVarNode *>::Element *E = p_function->body->variables.front(); E; E = E->next()) { - LocalVarNode *lv = E->get(); - for (int i = 0; i < current_class->variables.size(); i++) { - if (current_class->variables[i].identifier == lv->name) { - _add_warning(GDScriptWarning::SHADOWED_VARIABLE, lv->line, lv->name, itos(current_class->variables[i].line)); - } - } - } -#endif // DEBUG_ENABLED } void GDScriptParser::_check_class_blocks_types(ClassNode *p_class) { @@ -8349,6 +8338,11 @@ void GDScriptParser::_check_block_types(BlockNode *p_block) { if (lv->datatype.has_type && assign_type.may_yield && lv->assign->type == Node::TYPE_OPERATOR) { _add_warning(GDScriptWarning::FUNCTION_MAY_YIELD, lv->line, _find_function_name(static_cast<OperatorNode *>(lv->assign))); } + for (int i = 0; i < current_class->variables.size(); i++) { + if (current_class->variables[i].identifier == lv->name) { + _add_warning(GDScriptWarning::SHADOWED_VARIABLE, lv->line, lv->name, itos(current_class->variables[i].line)); + } + } #endif // DEBUG_ENABLED if (!_is_type_compatible(lv->datatype, assign_type)) { |