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

GDScript 2.0: Typed arrays do not propagate type information through functions returning Variant #59721

Open
duncathan opened this issue Mar 31, 2022 · 1 comment

Comments

@duncathan
Copy link

Godot version

4.0.alpha5

System information

Windows 10

Issue description

Array functions which return Variant (front(), back(), pop_front(), etc.) do not propagate the array's type information; they are always considered to return Variant. I'm unsure whether this is a bug per se (I can easily imagine that there may be no way to easily resolve it with the current type system), but it is certainly unintuitive behavior.

Steps to reproduce

var arr: Array[int] = [1, 2, 3]
var i := arr[0]
var j := arr.front()

Cannot infer the type of "j" variable because the initial value is Variant. Use explicit "Variant" type if this is intended.

Minimal reproduction project

No response

@Calinou Calinou added this to the 4.0 milestone Mar 31, 2022
@Calinou Calinou changed the title Typed arrays do not propagate type information through functions returning Variant GDScript 2.0: Typed arrays do not propagate type information through functions returning Variant Mar 31, 2022
@vnen vnen modified the milestones: 4.0, 4.1 Feb 22, 2023
@dalexeev
Copy link
Member

dalexeev commented Jun 15, 2023

It's documented, although I think we should add it to the class description too (plus info about typed arrays, see #78257).

This is a desirable feature, but it requires work on the core side (support for generic classes in PropertyInfo, DocData, etc.). 4.1-dev is now in feature freeze, I think it's too late to start working on this for 4.1.

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

No branches or pull requests

7 participants