diff options
author | George Marques <george@gmarqu.es> | 2018-09-10 19:29:25 -0300 |
---|---|---|
committer | George Marques <george@gmarqu.es> | 2018-09-19 11:17:46 -0300 |
commit | 726e836cd9b6eee5e060b694e076535ad5b5a7ae (patch) | |
tree | 94ca66ec674488d46ea80afe3d14f7681b14b23e /modules/gdscript/gdscript_editor.cpp | |
parent | e6a6ea65c7311175603a698b4051b90b2a112161 (diff) | |
download | redot-engine-726e836cd9b6eee5e060b694e076535ad5b5a7ae.tar.gz |
GDScript: Fix infinite loop in autocomplete
It happened when the definition of the variable contained the variable
itself.
Diffstat (limited to 'modules/gdscript/gdscript_editor.cpp')
-rw-r--r-- | modules/gdscript/gdscript_editor.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/modules/gdscript/gdscript_editor.cpp b/modules/gdscript/gdscript_editor.cpp index e74193e7ac..2ad6b42223 100644 --- a/modules/gdscript/gdscript_editor.cpp +++ b/modules/gdscript/gdscript_editor.cpp @@ -1376,11 +1376,11 @@ static bool _guess_identifier_type_from_base(const GDScriptCompletionContext &p_ for (int i = 0; i < base_type.class_type->variables.size(); i++) { GDScriptParser::ClassNode::Member m = base_type.class_type->variables[i]; if (m.identifier == p_identifier) { - if (m.data_type.has_type) { - r_type.type = m.data_type; - return true; - } if (m.expression) { + if (p_context.line == m.expression->line) { + // Variable used in the same expression + return false; + } if (_guess_expression_type(p_context, m.expression, r_type)) { return true; } @@ -1389,6 +1389,10 @@ static bool _guess_identifier_type_from_base(const GDScriptCompletionContext &p_ return true; } } + if (m.data_type.has_type) { + r_type.type = m.data_type; + return true; + } return false; } } |