You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-05 12:10:55 +00:00
GDScript: Fix issues with completion and super calls
- Make call errors use the call node instead of the calle, which will be empty on super calls. - Don't allow `super()` to be used within lambdas.
This commit is contained in:
@@ -2426,6 +2426,10 @@ void GDScriptAnalyzer::reduce_call(GDScriptParser::CallNode *p_call, bool p_is_a
|
||||
base_type = parser->current_class->base_type;
|
||||
base_type.is_meta_type = false;
|
||||
is_self = true;
|
||||
|
||||
if (p_call->callee == nullptr && !lambda_stack.is_empty()) {
|
||||
push_error("Cannot use `super()` inside a lambda.", p_call);
|
||||
}
|
||||
} else if (callee_type == GDScriptParser::Node::IDENTIFIER) {
|
||||
base_type = parser->current_class->get_datatype();
|
||||
base_type.is_meta_type = false;
|
||||
@@ -2494,12 +2498,12 @@ void GDScriptAnalyzer::reduce_call(GDScriptParser::CallNode *p_call, bool p_is_a
|
||||
}
|
||||
|
||||
if (is_self && parser->current_function != nullptr && parser->current_function->is_static && !is_static) {
|
||||
push_error(vformat(R"*(Cannot call non-static function "%s()" from static function "%s()".)*", p_call->function_name, parser->current_function->identifier->name), p_call->callee);
|
||||
push_error(vformat(R"*(Cannot call non-static function "%s()" from static function "%s()".)*", p_call->function_name, parser->current_function->identifier->name), p_call);
|
||||
} else if (!is_self && base_type.is_meta_type && !is_static) {
|
||||
base_type.is_meta_type = false; // For `to_string()`.
|
||||
push_error(vformat(R"*(Cannot call non-static function "%s()" on the class "%s" directly. Make an instance instead.)*", p_call->function_name, base_type.to_string()), p_call->callee);
|
||||
push_error(vformat(R"*(Cannot call non-static function "%s()" on the class "%s" directly. Make an instance instead.)*", p_call->function_name, base_type.to_string()), p_call);
|
||||
} else if (is_self && !is_static && !lambda_stack.is_empty()) {
|
||||
push_error(vformat(R"*(Cannot call non-static function "%s()" from a lambda function.)*", p_call->function_name), p_call->callee);
|
||||
push_error(vformat(R"*(Cannot call non-static function "%s()" from a lambda function.)*", p_call->function_name), p_call);
|
||||
}
|
||||
|
||||
call_type = return_type;
|
||||
@@ -2539,7 +2543,7 @@ 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->callee);
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user