GDScript: Allow using await on calls to void functions
This commit is contained in:
parent
a3816434a6
commit
a1309f1f42
@ -2467,7 +2467,7 @@ void GDScriptAnalyzer::reduce_call(GDScriptParser::CallNode *p_call, bool p_is_a
|
||||
} else if (GDScriptUtilityFunctions::function_exists(function_name)) {
|
||||
MethodInfo function_info = GDScriptUtilityFunctions::get_function_info(function_name);
|
||||
|
||||
if (!p_is_root && function_info.return_val.type == Variant::NIL && ((function_info.return_val.usage & PROPERTY_USAGE_NIL_IS_VARIANT) == 0)) {
|
||||
if (!p_is_root && !p_is_await && function_info.return_val.type == Variant::NIL && ((function_info.return_val.usage & PROPERTY_USAGE_NIL_IS_VARIANT) == 0)) {
|
||||
push_error(vformat(R"*(Cannot get return value of call to "%s()" because it returns "void".)*", function_name), p_call);
|
||||
}
|
||||
|
||||
@ -2514,7 +2514,7 @@ void GDScriptAnalyzer::reduce_call(GDScriptParser::CallNode *p_call, bool p_is_a
|
||||
} else if (Variant::has_utility_function(function_name)) {
|
||||
MethodInfo function_info = info_from_utility_func(function_name);
|
||||
|
||||
if (!p_is_root && function_info.return_val.type == Variant::NIL && ((function_info.return_val.usage & PROPERTY_USAGE_NIL_IS_VARIANT) == 0)) {
|
||||
if (!p_is_root && !p_is_await && function_info.return_val.type == Variant::NIL && ((function_info.return_val.usage & PROPERTY_USAGE_NIL_IS_VARIANT) == 0)) {
|
||||
push_error(vformat(R"*(Cannot get return value of call to "%s()" because it returns "void".)*", function_name), p_call);
|
||||
}
|
||||
|
||||
@ -2660,7 +2660,7 @@ void GDScriptAnalyzer::reduce_call(GDScriptParser::CallNode *p_call, bool p_is_a
|
||||
mark_lambda_use_self();
|
||||
}
|
||||
|
||||
if (!p_is_root && return_type.is_hard_type() && return_type.kind == GDScriptParser::DataType::BUILTIN && return_type.builtin_type == Variant::NIL) {
|
||||
if (!p_is_root && !p_is_await && return_type.is_hard_type() && return_type.kind == GDScriptParser::DataType::BUILTIN && return_type.builtin_type == Variant::NIL) {
|
||||
push_error(vformat(R"*(Cannot get return value of call to "%s()" because it returns "void".)*", p_call->function_name), p_call);
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,7 @@
|
||||
func wait() -> void:
|
||||
pass
|
||||
|
||||
func test():
|
||||
@warning_ignore(redundant_await)
|
||||
await wait()
|
||||
print("end")
|
@ -0,0 +1,2 @@
|
||||
GDTEST_OK
|
||||
end
|
Loading…
Reference in New Issue
Block a user