GDScript: Fix typing for await expression

Don't grab the type of the awaited value unless it's constant (which
makes it synchronous) or call (which always use the proper return type).
This commit is contained in:
George Marques 2021-10-14 20:30:06 -03:00
parent 749d89ae38
commit 84abb9a76c
No known key found for this signature in database
GPG Key ID: 046BD46A3201E43D
1 changed files with 12 additions and 3 deletions

View File

@ -1927,16 +1927,25 @@ void GDScriptAnalyzer::reduce_await(GDScriptParser::AwaitNode *p_await) {
p_await->set_datatype(await_type);
return;
}
GDScriptParser::DataType awaiting_type;
if (p_await->to_await->type == GDScriptParser::Node::CALL) {
reduce_call(static_cast<GDScriptParser::CallNode *>(p_await->to_await), true);
awaiting_type = p_await->to_await->get_datatype();
} else {
reduce_expression(p_await->to_await);
}
p_await->is_constant = p_await->to_await->is_constant;
p_await->reduced_value = p_await->to_await->reduced_value;
if (p_await->to_await->is_constant) {
p_await->is_constant = p_await->to_await->is_constant;
p_await->reduced_value = p_await->to_await->reduced_value;
GDScriptParser::DataType awaiting_type = p_await->to_await->get_datatype();
awaiting_type = p_await->to_await->get_datatype();
} else {
awaiting_type.kind = GDScriptParser::DataType::VARIANT;
awaiting_type.type_source = GDScriptParser::DataType::UNDETECTED;
}
p_await->set_datatype(awaiting_type);