summaryrefslogtreecommitdiffstats
path: root/modules/gdscript/gdscript_analyzer.cpp
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2023-09-19 09:03:42 +0200
committerRémi Verschelde <rverschelde@gmail.com>2023-09-19 09:03:42 +0200
commit3d3a9ee827893d9c3e0930ac71896262fbc4dff9 (patch)
treec53ab6116c670add3696e0bdf2cdc3810293d06f /modules/gdscript/gdscript_analyzer.cpp
parent9a1b4f338b3ea4bf7c3e9746669a43fd1e5560d7 (diff)
parent729c9b4d4b82c88de6adde34fc060fdb8727d116 (diff)
downloadredot-engine-3d3a9ee827893d9c3e0930ac71896262fbc4dff9.tar.gz
Merge pull request #81808 from anvilfolk/super-virtual
GDScript: Add check for `super()` methods not being implemented
Diffstat (limited to 'modules/gdscript/gdscript_analyzer.cpp')
-rw-r--r--modules/gdscript/gdscript_analyzer.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/modules/gdscript/gdscript_analyzer.cpp b/modules/gdscript/gdscript_analyzer.cpp
index 4b8d527881..077b30a7fe 100644
--- a/modules/gdscript/gdscript_analyzer.cpp
+++ b/modules/gdscript/gdscript_analyzer.cpp
@@ -3204,7 +3204,13 @@ void GDScriptAnalyzer::reduce_call(GDScriptParser::CallNode *p_call, bool p_is_a
bool is_constructor = (base_type.is_meta_type || (p_call->callee && p_call->callee->type == GDScriptParser::Node::IDENTIFIER)) && p_call->function_name == SNAME("new");
if (get_function_signature(p_call, is_constructor, base_type, p_call->function_name, return_type, par_types, default_arg_count, method_flags)) {
- // If the function require typed arrays we must make literals be typed.
+ // If the method is implemented in the class hierarchy, the virtual flag will not be set for that MethodInfo and the search stops there.
+ // Virtual check only possible for super() calls because class hierarchy is known. Node/Objects may have scripts attached we don't know of at compile-time.
+ if (p_call->is_super && method_flags.has_flag(METHOD_FLAG_VIRTUAL)) {
+ push_error(vformat(R"*(Cannot call the parent class' virtual function "%s()" because it hasn't been defined.)*", p_call->function_name), p_call);
+ }
+
+ // If the function requires typed arrays we must make literals be typed.
for (const KeyValue<int, GDScriptParser::ArrayNode *> &E : arrays) {
int index = E.key;
if (index < par_types.size() && par_types[index].has_container_element_type()) {