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
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
The text was updated successfully, but these errors were encountered:
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
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.
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 returnVariant
. 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
Minimal reproduction project
No response
The text was updated successfully, but these errors were encountered: