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

(cherry picked from commit 95f10c620d)
This commit is contained in:
Juan Linietsky 2017-08-08 11:44:49 -03:00 committed by Rémi Verschelde
parent b94c5a31cd
commit f4d6e37c2f
1 changed files with 5 additions and 2 deletions

View File

@ -1678,8 +1678,7 @@ void GDParser::_parse_block(BlockNode *p_block, bool p_static) {
StringName n = tokenizer->get_token_identifier();
tokenizer->advance();
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>();
@ -1709,6 +1708,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;