push variable later when created, to avoid self-referencing as a valid case, closes #6111

This commit is contained in:
Juan Linietsky 2017-08-08 11:44:49 -03:00
parent fab75bce3f
commit 95f10c620d

View file

@ -2369,8 +2369,7 @@ void GDParser::_parse_block(BlockNode *p_block, bool p_static) {
check_block = check_block->parent_block;
}
p_block->variables.push_back(n); //line?
p_block->variable_lines.push_back(tokenizer->get_token_line());
int var_line = tokenizer->get_token_line();
//must know when the local variable is declared
LocalVarNode *lv = alloc_node<LocalVarNode>();
@ -2400,6 +2399,10 @@ void GDParser::_parse_block(BlockNode *p_block, bool p_static) {
c->value = Variant();
assigned = c;
}
//must be added later, to avoid self-referencing.
p_block->variables.push_back(n); //line?
p_block->variable_lines.push_back(var_line);
IdentifierNode *id = alloc_node<IdentifierNode>();
id->name = n;