diff options
Diffstat (limited to 'modules/gdscript')
| -rw-r--r-- | modules/gdscript/gdscript.cpp | 7 | ||||
| -rw-r--r-- | modules/gdscript/gdscript_analyzer.cpp | 6 |
2 files changed, 5 insertions, 8 deletions
diff --git a/modules/gdscript/gdscript.cpp b/modules/gdscript/gdscript.cpp index 91f31174dd..258f1a80f7 100644 --- a/modules/gdscript/gdscript.cpp +++ b/modules/gdscript/gdscript.cpp @@ -1288,15 +1288,10 @@ String GDScript::_get_gdscript_reference_class_name(const GDScript *p_gdscript) } GDScript *GDScript::_get_gdscript_from_variant(const Variant &p_variant) { - Variant::Type type = p_variant.get_type(); - if (type != Variant::Type::OBJECT) - return nullptr; - Object *obj = p_variant; - if (obj == nullptr) { + if (obj == nullptr || obj->get_instance_id().is_null()) { return nullptr; } - return Object::cast_to<GDScript>(obj); } diff --git a/modules/gdscript/gdscript_analyzer.cpp b/modules/gdscript/gdscript_analyzer.cpp index 9ec53b2b66..30ac1f29b1 100644 --- a/modules/gdscript/gdscript_analyzer.cpp +++ b/modules/gdscript/gdscript_analyzer.cpp @@ -3875,7 +3875,6 @@ void GDScriptAnalyzer::reduce_ternary_op(GDScriptParser::TernaryOpNode *p_ternar void GDScriptAnalyzer::reduce_unary_op(GDScriptParser::UnaryOpNode *p_unary_op) { reduce_expression(p_unary_op->operand); - GDScriptParser::DataType operand_type = p_unary_op->operand->get_datatype(); GDScriptParser::DataType result; if (p_unary_op->operand == nullptr) { @@ -3884,6 +3883,8 @@ void GDScriptAnalyzer::reduce_unary_op(GDScriptParser::UnaryOpNode *p_unary_op) return; } + GDScriptParser::DataType operand_type = p_unary_op->operand->get_datatype(); + 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()); @@ -4026,7 +4027,8 @@ GDScriptParser::DataType GDScriptAnalyzer::type_from_variant(const Variant &p_va found = found->get_member(E).m_class; } - result = found->get_datatype(); + result.class_type = found; + result.script_path = ref->get_parser()->script_path; } else { result.kind = GDScriptParser::DataType::SCRIPT; result.native_type = scr->get_instance_base_type(); |