Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Callable.callv() will make call with wrong arguments if a const Array is passed #93600

Open
micalpixel opened this issue Jun 25, 2024 · 0 comments · May be fixed by #93636
Open

Callable.callv() will make call with wrong arguments if a const Array is passed #93600

micalpixel opened this issue Jun 25, 2024 · 0 comments · May be fixed by #93636

Comments

@micalpixel
Copy link

micalpixel commented Jun 25, 2024

Tested versions

  • Reproducible in 4.3.beta2.official [b75f048]

System information

Windows 10 - Godot 4.3.beta2.official [b75f048]

Issue description

Using Callable().callv() will result in a call using the wrong arguments, if the Array being passed is a const.
The bug does not occur if the Array being passed is a var.
The bug does not occur if we use Callable().bindv().call() instead.

Steps to reproduce

The following code can demonstrate the bug. The debugger does not show any errors or warnings.


const arr_const = ['one','two','three','four']
var arr_var = ['one','two','three','four']

func _ready() -> void:
	# non-const works
	somefunc.callv(arr_var)
	# const fails
	somefunc.callv(arr_const)
	# temporary workaround
	somefunc.bindv(arr_const).call()
	
func somefunc(v1,v2,v3,v4):
	print('%s,%s,%s,%s'% [v1,v2,v3,v4])

will print:

one,two,three,four
four,four,four,four
one,two,three,four

The first and third calls work as expected, with the four arguments in the arrays.
Only the second call, which used a const Array and .callv(), made a call with all arguments replaced by the last argument.

In this example, I use a function directly, but this can be reproduced with any Callable().

This seems like a similar issue as #69237, with a similar workaround, but in this case the correct number of arguments was passed.

Minimal reproduction project (MRP)

callablecheck.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants