diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2020-06-16 15:51:31 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-16 15:51:31 +0200 |
commit | 697897cc61e52fb34680c805f08ba31a633731ac (patch) | |
tree | 2c64b6c5238d4c2e1047a50d1178099e0565e2e4 /modules/gdscript/gdscript_parser.cpp | |
parent | 78d09a41639ec2c2f1e44541bd696058795a61c5 (diff) | |
parent | 54835a530210c9620973a63dd30ff1d6bbe43a96 (diff) |
Merge pull request #39275 from ThakeeNathees/shadowed-warning-for-loop-counter
Added shadowed var warning for `for` loop counter
Diffstat (limited to 'modules/gdscript/gdscript_parser.cpp')
-rw-r--r-- | modules/gdscript/gdscript_parser.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/modules/gdscript/gdscript_parser.cpp b/modules/gdscript/gdscript_parser.cpp index d2867cb77a..ca452bf008 100644 --- a/modules/gdscript/gdscript_parser.cpp +++ b/modules/gdscript/gdscript_parser.cpp @@ -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) { |