godotengine / godotengine/godot
Typed Arrays with a named enum type cannot be set using `Object.set`
- Dominant language
- C++
- Stars
- 117k
- Forks
- 26.8k
- PR merge metrics
- PR metrics pending
Description
### Tested versions
- reproducible in v4.4.dev2.mono.official [97ef3c837], v4.3.stable.mono.official [77dcf97d8] and v4.2.2.stable.mono.official [15073afe3]
### System information
Godot v4.3.stable.mono - Windows 10.0.22631 - GLES3 (Compatibility) - NVIDIA GeForce RTX 4070 Ti SUPER (NVIDIA; 32.0.15.6109) - AMD Ryzen 7 7800X3D 8-Core Processor (16 Threads)
### Issue description
If you declare an array with a named enum type, the `Object.set` method will not set that array's value, but should.
Please see code in steps to reproduce or MRP for more details.
### Steps to reproduce
Use the MRP, or create a single scene project with this script attached to a single Node2D and run it:
```gdscript
extends Node2D
enum THING {FOO, BAR, BAZ}
var my_typed_list: Array[THING] = []
func _ready() -> void:
self.set("my_typed_list", [THING.FOO, THING.BAR])
print("(Typed array) Should have 2 elements but doesn't: ", my_typed_list, " <--------- Incorrect")
my_typed_list = [THING.FOO, THING.BAR]
print("(Typed array) Should have 2 elements and does: ", my_typed_list, " <--------- Correct ")
```
Expected behavior: The array should print with 2 elements.
Actual behavior: The array prints with 0 elements.
### Minimal reproduction project (MRP)
[setenum.zip](https://github.com/user-attachments/files/17026222/setenum.zip)
Contributor guide
Research direction
Run the setenum.zip minimal reproduction project and inspect the _ready() calls to Object.set and the typed Array[THING] behavior. Trace the Object.set handling for named enum arrays, then verify that the reproduction prints two elements after the setter call, matching direct assignment.
Written by the indexing model from the issue text.
Assessment
- Domain
- game-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 38/100