diff options
| author | Rémi Verschelde <rverschelde@gmail.com> | 2023-06-15 10:39:59 +0200 |
|---|---|---|
| committer | Rémi Verschelde <rverschelde@gmail.com> | 2023-06-15 10:39:59 +0200 |
| commit | 3a319daa99abe751867cc34abfd97987e8ecb666 (patch) | |
| tree | 4d85cfd4864297d324beae26ca804b8c089d1258 /modules/gdscript | |
| parent | b1d307064869a52b84f48746f716fe797be20fcb (diff) | |
| parent | 25c90836fd408566b70be8b3d79b9dbafd2eaec1 (diff) | |
| download | redot-engine-3a319daa99abe751867cc34abfd97987e8ecb666.tar.gz | |
Merge pull request #77351 from anvilfolk/super-discard
GDScript: do not RETURN_VALUE_DISCARDED for `super()` inside `_init()`
Diffstat (limited to 'modules/gdscript')
3 files changed, 14 insertions, 2 deletions
diff --git a/modules/gdscript/gdscript_analyzer.cpp b/modules/gdscript/gdscript_analyzer.cpp index 13fd115c43..8251de2956 100644 --- a/modules/gdscript/gdscript_analyzer.cpp +++ b/modules/gdscript/gdscript_analyzer.cpp @@ -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; } diff --git a/modules/gdscript/tests/scripts/analyzer/features/virtual_super_implemented.gd b/modules/gdscript/tests/scripts/analyzer/features/virtual_super_implemented.gd new file mode 100644 index 0000000000..c447003619 --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/features/virtual_super_implemented.gd @@ -0,0 +1,10 @@ +class TestOne: + func _init(): + pass + +class TestTwo extends TestOne: + func _init(): + super() + +func test(): + pass diff --git a/modules/gdscript/tests/scripts/analyzer/features/virtual_super_implemented.out b/modules/gdscript/tests/scripts/analyzer/features/virtual_super_implemented.out new file mode 100644 index 0000000000..d73c5eb7cd --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/features/virtual_super_implemented.out @@ -0,0 +1 @@ +GDTEST_OK |
