summaryrefslogtreecommitdiff
path: root/modules/gdscript
diff options
context:
space:
mode:
authorGeorge Marques <george@gmarqu.es>2023-02-24 13:42:59 -0300
committerGeorge Marques <george@gmarqu.es>2023-02-24 14:06:02 -0300
commitdefa46bfd1d9e391ced336306c93ecdff38a7ce7 (patch)
tree924e0755acedeabfbc136f5f206996208f7bba20 /modules/gdscript
parent6296b46008fb8d8e5cb9b60af05fa1ea26b8f600 (diff)
GDScript: Don't use validated call for vararg methods
Since they may have runtime type validation, we cannot use the validated call.
Diffstat (limited to 'modules/gdscript')
-rw-r--r--modules/gdscript/gdscript_byte_codegen.cpp4
-rw-r--r--modules/gdscript/tests/scripts/analyzer/warnings/lambda_unused_arg.gd2
2 files changed, 3 insertions, 3 deletions
diff --git a/modules/gdscript/gdscript_byte_codegen.cpp b/modules/gdscript/gdscript_byte_codegen.cpp
index 5b092e3691..d6f21d297a 100644
--- a/modules/gdscript/gdscript_byte_codegen.cpp
+++ b/modules/gdscript/gdscript_byte_codegen.cpp
@@ -1058,7 +1058,7 @@ void GDScriptByteCodeGenerator::write_call_gdscript_utility(const Address &p_tar
void GDScriptByteCodeGenerator::write_call_utility(const Address &p_target, const StringName &p_function, const Vector<Address> &p_arguments) {
bool is_validated = true;
if (Variant::is_utility_function_vararg(p_function)) {
- is_validated = true; // Vararg works fine with any argument, since they can be any type.
+ is_validated = false; // Vararg needs runtime checks, can't use validated call.
} else if (p_arguments.size() == Variant::get_utility_function_argument_count(p_function)) {
bool all_types_exact = true;
for (int i = 0; i < p_arguments.size(); i++) {
@@ -1107,7 +1107,7 @@ void GDScriptByteCodeGenerator::write_call_builtin_type(const Address &p_target,
// Check if all types are correct.
if (Variant::is_builtin_method_vararg(p_type, p_method)) {
- is_validated = true; // Vararg works fine with any argument, since they can be any type.
+ is_validated = false; // Vararg needs runtime checks, can't use validated call.
} else if (p_arguments.size() == Variant::get_builtin_method_argument_count(p_type, p_method)) {
bool all_types_exact = true;
for (int i = 0; i < p_arguments.size(); i++) {
diff --git a/modules/gdscript/tests/scripts/analyzer/warnings/lambda_unused_arg.gd b/modules/gdscript/tests/scripts/analyzer/warnings/lambda_unused_arg.gd
index 6fc90ea29c..1e5c10b7d5 100644
--- a/modules/gdscript/tests/scripts/analyzer/warnings/lambda_unused_arg.gd
+++ b/modules/gdscript/tests/scripts/analyzer/warnings/lambda_unused_arg.gd
@@ -1,4 +1,4 @@
func test():
var lambda := func(unused: Variant) -> void:
pass
- lambda.call()
+ lambda.call("something")