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
In 4.0.3 this works for constants and literals, but the bug remains for variables. In fact, the as operator only works correctly with objects, it has always worked inconsistently with Variant types (raises a runtime error instead of returning a default value), we should probably change this behavior.
Also note the difference between casting and conversion, as should not convert an array at runtime and creating a new one (except if no conversion is possible), it should allow the static analyzer to change the type interpretation. For conversion, there is Array.assign() method and there is PR #71336 for a typed constructor.
We have not resolved all the design issues of typed arrays, but I don’t think that type casting should not create new data, only change the static type of the expression (when casting to a supertype) and provide a safe value in case of a type mismatch at runtime (when casting to a subtype). However, we introduced this behavior for array literals.
In any case, we cannot move forward until a consensus is found in the discussion. It would be nice to document the current implementation, but I don't think it's urgent.
Godot version
4.0.dev.custom_build.3bebbcacd
System information
manjaro linux
Issue description
yields
while it should cast elements to int I believe.
Steps to reproduce
Run the above.
Minimal reproduction project
No response
The text was updated successfully, but these errors were encountered: