mirror of
https://github.com/godotengine/godot.git
synced 2024-12-09 10:09:20 +08:00
Merge pull request #39276 from ThakeeNathees/predefined-check-for-loop-counter
Added predefined var check for `for` loop counter
This commit is contained in:
commit
150ba031de
@ -3179,6 +3179,15 @@ void GDScriptParser::_parse_block(BlockNode *p_block, bool p_static) {
|
|||||||
IdentifierNode *id = alloc_node<IdentifierNode>();
|
IdentifierNode *id = alloc_node<IdentifierNode>();
|
||||||
id->name = tokenizer->get_token_identifier();
|
id->name = tokenizer->get_token_identifier();
|
||||||
|
|
||||||
|
BlockNode *check_block = p_block;
|
||||||
|
while (check_block) {
|
||||||
|
if (check_block->variables.has(id->name)) {
|
||||||
|
_set_error("Variable \"" + String(id->name) + "\" already defined in the scope (at line " + itos(check_block->variables[id->name]->line) + ").");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
check_block = check_block->parent_block;
|
||||||
|
}
|
||||||
|
|
||||||
tokenizer->advance();
|
tokenizer->advance();
|
||||||
|
|
||||||
if (tokenizer->get_token() != GDScriptTokenizer::TK_OP_IN) {
|
if (tokenizer->get_token() != GDScriptTokenizer::TK_OP_IN) {
|
||||||
|
Loading…
Reference in New Issue
Block a user