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
godot support OOP, so we can extend class :But it seem like gotdot cannot understand class in container
Im not sure is this a feature?
Steps to reproduce
I have class A and B. Class B extend from A.
var a:A
var b:B
a=b but this cannot pass:
var a:Array[A]
var b:Array[B]
a=b
error:Value of type "Array[B]" cannot be assigned to a variable of type "Array[A]"
Minimal reproduction project (MRP)
N/A
The text was updated successfully, but these errors were encountered:
This is not a bug. Arrays are passed by reference; they do not copy the entire content. Otherwise you would get:
vara: Array[Node2D]
varb: Array[Node]
b=a# Now `b` refers to the same array as `a`.b.append(Label.new()) # Valid, `Label` is a subtype of `Node`.print(a[0]) # Invalid, `Label` is **not** a subtype of `Node2D`.
Probably the only way this would work is if the GDScript supported read/write qualifiers. But it's too difficult.
Tested versions
godot 4.2.2 statble
System information
windows 10
Issue description
godot support OOP, so we can extend class :But it seem like gotdot cannot understand class in container
Im not sure is this a feature?
Steps to reproduce
I have class A and B. Class B extend from A.
var a:A
var b:B
a=b
but this cannot pass:
var a:Array[A]
var b:Array[B]
a=b
error:Value of type "Array[B]" cannot be assigned to a variable of type "Array[A]"
Minimal reproduction project (MRP)
N/A
The text was updated successfully, but these errors were encountered: