godotengine / godotengine/godot-cpp

Calling a varargs function with no arguments leads to error

Open
#1,038 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: fc6dfefffd4d7872ee0d2640549d43ca4b63c039
godot-cpp: f9ccf28374af9fb93b4f0def4b0b861a185a35e2
OS: Windows 10

Calling a varargs function from GDScript with no parameters leads to this error.
```
E 0:00:00:0489 standard_gui.gd:17 @ _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:17 @ _ready()
```

GDScript call
```GDScript
func _ready() -> void:
var osf := OpenSeeFace.new()
osf.start()
```

C++ method
```C++
Error OpenSeeFace::start(const Variant **p_args, GDExtensionInt p_arg_count, GDExtensionCallError &p_error) {
_logger->info(String("Starting OpenSeeFace"));

... omitted ...

return OK;
}

... elsewhere ...

void OpenSeeFace::_bind_methods() {
{
MethodInfo mi;
mi.name = "start";
ClassDB::bind_vararg_method(METHOD_FLAG_VARARG, "start", &OpenSeeFace::start, mi, std::vector{Variant(0)});
}
}
```

The result is the same if the default args are omitted from the method bind.

Passing a dummy value in GDScript makes things work as expected.
```GDScript
func _ready() -> void:
var osf := OpenSeeFace.new()
osf.start(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.