diff options
author | Juan Linietsky <reduzio@gmail.com> | 2017-08-08 11:44:49 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2017-08-08 11:44:49 -0300 |
commit | 95f10c620d475245e62bed81cb981aa47c926d0b (patch) | |
tree | 283e64ee16c3c0a87260e1f4220e6ab132b4c4bf /modules | |
parent | fab75bce3fcf6355accdb0e2ef23aef45c996b61 (diff) |
push variable later when created, to avoid self-referencing as a valid case, closes #6111
Diffstat (limited to 'modules')
-rw-r--r-- | modules/gdscript/gd_parser.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/modules/gdscript/gd_parser.cpp b/modules/gdscript/gd_parser.cpp index 36aa249398..9023fd4bf4 100644 --- a/modules/gdscript/gd_parser.cpp +++ b/modules/gdscript/gd_parser.cpp @@ -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; |