Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypedArray does not work with Inheritence #89959

Closed
betalars opened this issue Mar 27, 2024 · 4 comments
Closed

TypedArray does not work with Inheritence #89959

betalars opened this issue Mar 27, 2024 · 4 comments
Labels

Comments

@betalars
Copy link
Contributor

betalars commented Mar 27, 2024

Tested versions

  • reproducible in v4.2.1.stable

System information

nixos unstable

Issue description

When trying to assign a typed array to an array of a parent type, godot will raise an error.

Steps to reproduce

  1. create a new script
  2. write this snippet into the _ready function
var node_array: Array[Node]
var node_3d_array: Array[Node3D] = []

node_array = node_3d_array

Expected Result:
It is allowed to assign an array of inherited types to a typed array

Observed result:
Error: Value of Array[Node3D] cannot be assigned to a variable of type "Array[Node]".

Minimal reproduction project (MRP)

N/A

@betalars
Copy link
Contributor Author

Btw: This is not a too critical bug, as you can simply use the parent type for your array instead as a workaround.

@AThousandShips
Copy link
Member

This is a known limitation, see the discussion in:

Consolidating there

@AThousandShips AThousandShips closed this as not planned Won't fix, can't repro, duplicate, stale Mar 27, 2024
@betalars
Copy link
Contributor Author

Wait, this is intended? Okay I did not see that coming.

@AThousandShips
Copy link
Member

AThousandShips commented Mar 27, 2024

See the discussion, it's a known limitation, and being discussed how it should work, it's not intended necessarily, we just need to work out how it should work, you'll see the details there

Also try

node_array.assign(node_3d_array)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants