-
-
Notifications
You must be signed in to change notification settings - Fork 21.3k
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::bind no longer unwraps arrays. Cannot convert argument 1 from [missing argptr, type unknown] #64668
Comments
Since this is not a bug, but a missing feature, it should be tracked in the proposals repo with a proper proposal. There is one made recently, in fact: godotengine/godot-proposals#6034. So closing this in favor of that. |
@YuriSizov Why not leave it open until #71000 closes it? |
Because this is a feature proposal and feature proposals are tracked in the proposals repo. And there is a feature proposal for it, which that PR will also close. |
Restores 3.x functionality that was removed in the Signal/Callable refactor of 4.0. Fixes godotengine#64668. Implements godotengine/godot-proposals#6034 Usage: ```GDScript callable.bindv([arg1,arg2,arg3]) ```
Restores 3.x functionality that was removed in the Signal/Callable refactor of 4.0. Fixes godotengine#64668. Implements godotengine/godot-proposals#6034 Usage: ```GDScript callable.bindv([arg1,arg2,arg3]) ```
Godot version
Godot 4 Alpha 14
System information
Windows 11/64, RTX 3070, Vulkan
Issue description
The key issue is that the change from
Object.connect(signal..., binds[])
andCallable(obj, signal).bind()
have changed behavior with bind, which no longer unwraps arrays.Another aspect is that we apparently have no ability to receive, create or pass along
varargs
. So all C++ functions that receive varargs can only be called directly, and not in derivative functions.If either there was a way to convert an array into a vararg, or the behavior stayed the same, it wouldn't be an issue. But because both happened it became an issue.
I wrote my own connect wrapper function to protect my game signal connects from the quirks in the engine. Try to connect more than once, and get console spam. Disconnect when not connected and get spammed. Disconnect and reconnecting scenes from the tree, and state machines with states reusing timers and other reasons means signals are connecting and disconnecting all the time. I don't want console spam to slow the engine, and I don't to write a few lines of validation code on every signal connection. Hence a signal wrapper.
However now Alpha14 broke it, it seems in #63595. Before, the
binds
array was unwrapped. Nowbind
takes a vararg. Any passed array no longer gets unwrapped and the whole array is accepted as one argument.This might work ok if we could receive, process, and create varargs. AFAIK we can't. So effectively any C++ vararg function treats GDscript as a second class citizen as we can't derive from those classes, can't override them, and can't wrap them.
Steps to reproduce
Here is my reconnect function, a signal connection, and the called function. This has worked fine until now, including the GD3 equivalent w/o Callable.
When the callback occurs I get this error:
I've found I can change my called function declaration. Kinda hacky and I lose static typing.
I've also found I can create a Callable in the client call. Exactly the kind of thing I wanted to avoid. It's only two extra words and formatting, but I have to do it across my whole codebase only because it appears that I can't convert
binds[]
into a vararg or use vararg as a function declaration.Also the docs are out of date. They still say I can pass binds to connect, though I cannot.
The text was updated successfully, but these errors were encountered: