diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2022-10-31 10:59:27 +0100 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2022-10-31 10:59:27 +0100 |
commit | 213ba466727d00c5a70438b638ca03b2f83c6437 (patch) | |
tree | 55e49142a2099859fe4efd78581298f835fcf2eb /modules/gdscript | |
parent | 8b1a42cd477d3144e0755797efb43719db748ae1 (diff) | |
parent | b7f0ab13a4c4f4af108bbe870d625e1b499f6d58 (diff) |
Merge pull request #68065 from zCubed3/fix_min_max_crash
`GDScriptAnalyzer` Fix math utilities crashing when invalid args are passed
Diffstat (limited to 'modules/gdscript')
-rw-r--r-- | modules/gdscript/gdscript_analyzer.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/modules/gdscript/gdscript_analyzer.cpp b/modules/gdscript/gdscript_analyzer.cpp index 46904f0f9d..1401e4b94b 100644 --- a/modules/gdscript/gdscript_analyzer.cpp +++ b/modules/gdscript/gdscript_analyzer.cpp @@ -2425,9 +2425,15 @@ void GDScriptAnalyzer::reduce_call(GDScriptParser::CallNode *p_call, bool p_is_a switch (err.error) { case Callable::CallError::CALL_ERROR_INVALID_ARGUMENT: { - PropertyInfo wrong_arg = function_info.arguments[err.argument]; + String expected_type_name; + if (err.argument < function_info.arguments.size()) { + expected_type_name = type_from_property(function_info.arguments[err.argument]).to_string(); + } else { + expected_type_name = Variant::get_type_name((Variant::Type)err.expected); + } + push_error(vformat(R"*(Invalid argument for "%s()" function: argument %d should be %s but is %s.)*", function_name, err.argument + 1, - type_from_property(wrong_arg).to_string(), p_call->arguments[err.argument]->get_datatype().to_string()), + expected_type_name, p_call->arguments[err.argument]->get_datatype().to_string()), p_call->arguments[err.argument]); } break; case Callable::CallError::CALL_ERROR_INVALID_METHOD: |