godotengine / godotengine/godot

Exported Array default is read-only when not serialized

Open
#114,342 3 comments 4 reactions 0 assignees View on GitHub
bug needs testing topic:core topic:gdscript
Dominant language
C++
Stars
117k
Forks
26.8k
PR merge metrics
PR metrics pending

Description

### Tested versions

- Reproducible: v4.6.beta2.official [551ce8d47], v4.5.1.stable.official [f62fdbde1]

### System information

Godot v4.6.beta2 - macOS Sequoia (15.5.0) - Multi-window, 2 monitors - Metal (Mobile) - integrated Apple M2 Max (Apple8) - Apple M2 Max (12 threads) - 64.00 GiB memory

### Issue description

When a Resource has an exported typed Array with a default value (e.g. @export var arr: Array[String] = ["a"]), and that property is not explicitly serialized into the .tres, loading the resource from disk makes the array read_only (is_read_only() == true).
The same resource created via ResourceA.new() yields is_read_only() == false. This difference breaks parity between “default value in script” and “default value used by a loaded resource”.

### Steps to reproduce

1. Open the project.
2. Right-click res://validator.gd and select Run.
3. Check the Output.

### Minimal reproduction project (MRP)

[array-readonly.zip](https://github.com/user-attachments/files/24343262/array-readonly.zip)

Contributor guide

Open the contributing guide

Research direction

Start with the minimal reproduction project and run res://validator.gd as described, comparing the read-only state of the newly created resource with the resource loaded from disk. Trace the exported typed Array default through resource loading and serialization. Done means an unserialized default Array has the same writable behavior after loading as it does from Resource.new().

Written by the indexing model from the issue text.

Assessment

Tech stack
godot
Domain
game-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
56/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.