Merge pull request #39275 from ThakeeNathees/shadowed-warning-for-loop-counter

Added shadowed var warning for `for` loop counter
This commit is contained in:
Rémi Verschelde 2020-06-16 15:51:31 +02:00 committed by GitHub
commit 697897cc61
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -3180,6 +3180,13 @@ void GDScriptParser::_parse_block(BlockNode *p_block, bool p_static) {
IdentifierNode *id = alloc_node<IdentifierNode>();
id->name = tokenizer->get_token_identifier();
#ifdef DEBUG_ENABLED
for (int j = 0; j < current_class->variables.size(); j++) {
if (current_class->variables[j].identifier == id->name) {
_add_warning(GDScriptWarning::SHADOWED_VARIABLE, id->line, id->name, itos(current_class->variables[j].line));
}
}
#endif // DEBUG_ENABLED
BlockNode *check_block = p_block;
while (check_block) {