godotengine / godotengine/godot-cpp

TypedArray<T> operator [] returning Variant makes little sence.

Open
#1,482 3 comments 1 reaction 0 assignees View on GitHub
discussion enhancement
Dominant language
C++
Stars
2.7k
Forks
809
Avg merge
1d 3h
Merged PRs (30d)
8

Description

### Godot version

4.2

### godot-cpp version

4.2

### System information

Win 10

### Issue description

When using TypedArray I think the one would expect that accessing entries with operator [] will return you variable of type T. Instead it returns Variant, which is loosing all point to use TypedArray in first place.

This should give compilation error:
```
TypedArray a;
Dictionaty d = a[0];
```
As well as this construction is a bit annoying:
```
TypedArray a;
Node* n = (Node*) (Object*) a[0]; //beacuse varinat can only be cast to Object*
```

### Steps to reproduce

-

### Minimal reproduction project

-

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.