summaryrefslogtreecommitdiffstats
path: root/modules/gdscript/gdscript_compiler.cpp
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2023-01-30 20:26:58 +0100
committerRémi Verschelde <rverschelde@gmail.com>2023-01-30 20:26:58 +0100
commit08ec942e1ffb4d2680cd97dcd572f1c573a31b21 (patch)
tree3ed9f2f040b8bd51a8cd6febc73ba13c3d59a23d /modules/gdscript/gdscript_compiler.cpp
parent58a0c4c69ea1af3268a44c3c087484c7f6aa38b0 (diff)
parent011b3895db28231159bac57a3375ce59ad704d2e (diff)
downloadredot-engine-08ec942e1ffb4d2680cd97dcd572f1c573a31b21.tar.gz
Merge pull request #72390 from vonagam/fix-allowed-vararg-ptrcall
GDScript: Fix vararg method calls with exact arguments
Diffstat (limited to 'modules/gdscript/gdscript_compiler.cpp')
-rw-r--r--modules/gdscript/gdscript_compiler.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/modules/gdscript/gdscript_compiler.cpp b/modules/gdscript/gdscript_compiler.cpp
index c78dd1528f..6acdc9f212 100644
--- a/modules/gdscript/gdscript_compiler.cpp
+++ b/modules/gdscript/gdscript_compiler.cpp
@@ -196,7 +196,11 @@ static bool _is_exact_type(const PropertyInfo &p_par_type, const GDScriptDataTyp
}
}
-static bool _have_exact_arguments(const MethodBind *p_method, const Vector<GDScriptCodeGenerator::Address> &p_arguments) {
+static bool _can_use_ptrcall(const MethodBind *p_method, const Vector<GDScriptCodeGenerator::Address> &p_arguments) {
+ if (p_method->is_vararg()) {
+ // ptrcall won't work with vararg methods.
+ return false;
+ }
if (p_method->get_argument_count() != p_arguments.size()) {
// ptrcall won't work with default arguments.
return false;
@@ -563,7 +567,7 @@ GDScriptCodeGenerator::Address GDScriptCompiler::_parse_expression(CodeGen &code
self.mode = GDScriptCodeGenerator::Address::SELF;
MethodBind *method = ClassDB::get_method(codegen.script->native->get_name(), call->function_name);
- if (_have_exact_arguments(method, arguments)) {
+ if (_can_use_ptrcall(method, arguments)) {
// Exact arguments, use ptrcall.
gen->write_call_ptrcall(result, self, method, arguments);
} else {
@@ -613,7 +617,7 @@ GDScriptCodeGenerator::Address GDScriptCompiler::_parse_expression(CodeGen &code
}
if (ClassDB::class_exists(class_name) && ClassDB::has_method(class_name, call->function_name)) {
MethodBind *method = ClassDB::get_method(class_name, call->function_name);
- if (_have_exact_arguments(method, arguments)) {
+ if (_can_use_ptrcall(method, arguments)) {
// Exact arguments, use ptrcall.
gen->write_call_ptrcall(result, base, method, arguments);
} else {