1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-05 12:10:55 +00:00

Add opt-in GDScript warning for when calling coroutine without await

This commit is contained in:
Mikael Hermansson
2025-06-24 14:43:50 +02:00
parent ebc36a7225
commit a3e58a385f
8 changed files with 29 additions and 2 deletions

View File

@@ -3756,8 +3756,14 @@ void GDScriptAnalyzer::reduce_call(GDScriptParser::CallNode *p_call, bool p_is_a
}
}
if (call_type.is_coroutine && !p_is_await && !p_is_root) {
push_error(vformat(R"*(Function "%s()" is a coroutine, so it must be called with "await".)*", p_call->function_name), p_call);
if (call_type.is_coroutine && !p_is_await) {
if (p_is_root) {
#ifdef DEBUG_ENABLED
parser->push_warning(p_call, GDScriptWarning::MISSING_AWAIT);
#endif // DEBUG_ENABLED
} else {
push_error(vformat(R"*(Function "%s()" is a coroutine, so it must be called with "await".)*", p_call->function_name), p_call);
}
}
p_call->set_datatype(call_type);