Merge pull request #77351 from anvilfolk/super-discard

GDScript: do not RETURN_VALUE_DISCARDED for `super()` inside `_init()`
This commit is contained in:
Rémi Verschelde 2023-06-15 10:39:59 +02:00
commit 3a319daa99
No known key found for this signature in database
GPG Key ID: C3336907360768E1
3 changed files with 14 additions and 2 deletions

View File

@ -3130,7 +3130,8 @@ void GDScriptAnalyzer::reduce_call(GDScriptParser::CallNode *p_call, bool p_is_a
}
#ifdef DEBUG_ENABLED
if (p_is_root && return_type.kind != GDScriptParser::DataType::UNRESOLVED && return_type.builtin_type != Variant::NIL) {
if (p_is_root && return_type.kind != GDScriptParser::DataType::UNRESOLVED && return_type.builtin_type != Variant::NIL &&
!(p_call->is_super && p_call->function_name == GDScriptLanguage::get_singleton()->strings._init)) {
parser->push_warning(p_call, GDScriptWarning::RETURN_VALUE_DISCARDED, p_call->function_name);
}
@ -4718,7 +4719,7 @@ bool GDScriptAnalyzer::get_function_signature(GDScriptParser::Node *p_source, bo
}
if (p_is_constructor) {
function_name = "_init";
function_name = GDScriptLanguage::get_singleton()->strings._init;
r_static = true;
}

View File

@ -0,0 +1,10 @@
class TestOne:
func _init():
pass
class TestTwo extends TestOne:
func _init():
super()
func test():
pass