godotengine / godot-cpp

C++ bindings for the Godot script API
MIT License
1.75k stars 578 forks source link

Calling varargs methods without arguments causes a validated call failure #1641

Closed Ivorforce closed 6 days ago

Ivorforce commented 1 week ago

Godot version

4.3

godot-cpp version

4.3 (56571dc584ee7d14919996c6d58fb5b35e64af63)

System information

macOS

Issue description

When calling a varargs method without arguments, you get a failure:

5 • 0:00:00:0653 main.gd:73 @ _ready): Vararg methods don't have validated call support. This is most likely an engine bug.

Varargs calls are not supposed to be validated, so it's probably wrong that it tries to validated-call it in the first place: https://github.com/godotengine/godot/blob/5efd124ca10bf46df62fa2441d80589777e54a5a/modules/gdscript/gdscript_compiler.cpp#L237

This may have to do with the fact that MethodBind.hint_flags is never set (neither to vararg static, nor to p_flags) - but then again, I think it's supposed to be determined automatically? I'm not sure, I don't know the source code well enough to provide a quick fix.

I don't think this issue occurs in upstream godot, but I haven't extensively checked.

Steps to reproduce

  1. Add and bind varargs function
  2. Call from GDScript without args

Minimal reproduction project

git clone https://github.com/Ivorforce/godot-cpp.git --branch no-arg-varargs

(or just add as remote / checkout branch)

https://github.com/Ivorforce/godot-cpp/tree/no-arg-varargs

fwsGonzo commented 1 week ago

I've had the same problem, and worked around it by making the all function parameters a single varargs

dsnopek commented 1 week ago

Thanks!

Looks like this is caused by a fairly silly bug in Godot. I just posted PR https://github.com/godotengine/godot/pull/99403 which fixes this in my testing. Please let me know if it works for you!