summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Marques <george@gmarqu.es>2020-08-17 20:49:04 -0300
committerGeorge Marques <george@gmarqu.es>2020-08-17 20:49:04 -0300
commitf374021d52990189d41ca1c3f9353e381e4c5c4e (patch)
tree2e6aa596790b28a447a03cb72271fbbca1e91942
parent9ecd042e785198fcad3847463aff345bf996a640 (diff)
GDSript: Prevent crash when completing unary operators
-rw-r--r--modules/gdscript/gdscript_analyzer.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/modules/gdscript/gdscript_analyzer.cpp b/modules/gdscript/gdscript_analyzer.cpp
index c1c1cc80fc..0768dd05e5 100644
--- a/modules/gdscript/gdscript_analyzer.cpp
+++ b/modules/gdscript/gdscript_analyzer.cpp
@@ -2509,6 +2509,12 @@ void GDScriptAnalyzer::reduce_unary_op(GDScriptParser::UnaryOpNode *p_unary_op)
GDScriptParser::DataType result;
+ if (p_unary_op->operand == nullptr) {
+ result.kind = GDScriptParser::DataType::VARIANT;
+ p_unary_op->set_datatype(result);
+ return;
+ }
+
if (p_unary_op->operand->is_constant) {
p_unary_op->is_constant = true;
p_unary_op->reduced_value = Variant::evaluate(p_unary_op->variant_op, p_unary_op->operand->reduced_value, Variant());