Open smedelyan opened 6 months ago
This is specifically for Array[String]
and that the passed argument isn't an Array[String]
but just an Array
, if you use:
func _ready() -> void:
var arr : Array[String] = ["one", "two", "three"]
var callable: Callable = test.bind(arr)
callable.call()
func test(arr: Array[String]) -> void:
for e in arr:
print(e)
It works, this is related to general issues with typed arrays, unsure what the specific error is here, the "Callable to Array" is likely a separate issue with how the error printing is done
Thank you very much 🐳 My issue is solved now. Feel free to close this issue or keep it open / create a new one for the error printing
It's still an issue that it doesn't handle the conversion properly, even without the weirdness of the error message, might already be reported though
Same core issue as #91048, Packed Arrays
do not coerce to typed arrays, only to Array
.
func _ready():
var callableOK: Callable = TestOK.bind(["one", "two", "three"])
callableOK.call()
#var callableProblem: Callable = TestProblem.bind(["one", "two", "three"])
#callableProblem.call()
func TestProblem(arr: Array[String]) -> void:
print("TestProblem arr: %s" % arr)
func TestOK(arr: PackedStringArray) -> void:
print("TestOK arr: %s" % arr)
Tested versions
4.2.4
System information
Windows - Godot 4.2.4
Issue description
I can't bind arguments to a callable that accepts single array as argument
Steps to reproduce
Make this code run:
It will fail with the error like
Invalid type in function '...' Cannot convert argument 1 from Callable to Array
Minimal reproduction project (MRP)
N/A