You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Reproducible in v4.3.stable.official [77dcf97]
No other versions were tested.
System information
macOS Sonoma 14.4, M3 Processor
Issue description
When returning typed arrays for inner classes from a function by way of the Array Array(base: Array, type: int, class_name: StringName, script: Variant) constructor, a runtime error occurs. The example only contains the case for inner classes, but in my testing it also seemed to fail when trying to return an array of typed nodes (class_name at start of file).
I came across this behaviour when I tried filtering child nodes (get_children()) and returning only those of a specific class.
The result of the filtering step is an untyped array I tried turning into a typed array using the above constructor.
Example Code:
class_nameMyNodeextendsNodeclassData:
varvaluepassfunc_ready() ->void:
vartyped_array:=create_array()
funccreate_array() ->Array[Data]:
varuntyped_array:= [Data.new()]
vardata:=untyped_array[0] asData# Fails with error:# Trying to return an array of type "Array[RefCounted]" where expected return type is "Array[Data]".#return Array(untyped_array, TYPE_OBJECT, StringName(data.get_class()), null)# Even weirder: # Trying to return an array of type "Array[Data]" where expected return type is "Array[Data]".#return Array(untyped_array, TYPE_OBJECT, "Data", null)# Also fails:# Trying to return an array of type "Array[MyNode.Data]" where expected return type is "Array[Data]".#return Array(untyped_array, TYPE_OBJECT, "MyNode.Data", null)vartyped_array : Array[Data] = []
forvalinuntyped_array:
typed_array.push_back(val)
# This prints "RefCounted" which is weird because type hints actually work and suggest `value`# when accessing an element of this array.print(typed_array.get_typed_class_name())
returntyped_array
Steps to reproduce
Write a typed function returning a typed array
Try to use the typed array constructor with an inner class or a node class (from class_name)
Run project, fail when the function tries to return
Tested versions
No other versions were tested.
System information
macOS Sonoma 14.4, M3 Processor
Issue description
When returning typed arrays for inner classes from a function by way of the
Array Array(base: Array, type: int, class_name: StringName, script: Variant)
constructor, a runtime error occurs. The example only contains the case for inner classes, but in my testing it also seemed to fail when trying to return an array of typed nodes (class_name
at start of file).I came across this behaviour when I tried filtering child nodes (
get_children()
) and returning only those of a specific class.The result of the filtering step is an untyped array I tried turning into a typed array using the above constructor.
Example Code:
Steps to reproduce
class_name
)Minimal reproduction project (MRP)
array_type_error.zip
The text was updated successfully, but these errors were encountered: