godotengine / godotengine/godot-cpp

Calling a varargs function with the exact amount of expected args leads to error

Open
#1,068 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
C++
Stars
2.7k
Forks
809
Avg merge
1d 3h
Merged PRs (30d)
8

Description

godot: v4.0.stable.custom_build [92bee43ad]
godot-cpp: 9d1c396c54fc3bdfcc7da4f3abcb52b14f6cce8f
OS: Windows 10

Calling a varargs function from GDScript with the exact amount of registered parameters leads to this error. Might be related to #1038
```
E 0:00:02:0823 standard_gui.gd:27 @ _ready(): Vararg methods don't have ptrcall support. This is most likely an engine bug.
Condition "vararg" is true.
core\extension\gdextension.cpp:195 @ GDExtensionMethodBind::ptrcall()
standard_gui.gd:27 @ _ready()
runner_selection.gd:225 @ ()
```
GDScript call
```gdscript
func _ready() -> void:
var mf := MeowFace.new()
mf.data_received.connect(func(data: MeowFaceData) -> void:
print(JSON.stringify(data.get_blend_shapes(), "\t"))
)
add_child(mf)

mf.start("192.168.88.229", 21412)
```
C++
```c++
Error MeowFace::start(const Variant **p_args, GDExtensionInt p_arg_count, GDExtensionCallError &p_error) {
...
}

void MeowFace::_bind_methods() {
{
MethodInfo mi;
mi.name = "start";
mi.arguments.push_back(PropertyInfo(Variant::STRING, "address"));
mi.arguments.push_back(PropertyInfo(Variant::INT, "port"));
ClassDB::bind_vararg_method(METHOD_FLAG_VARARG, "start", &MeowFace::start, mi);
}

...
}
```

Passing an extra dummy value makes things work as expected.
```gdscript
func _ready() -> void:
var mf := MeowFace.new()
add_child(mf)

mf.start("192.168.88.229", 21412, 0)
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.