godotengine / godotengine/godot
Exported arrays in extended scripts of inherited scenes all have the type of the first array declared (yes, again)
- Dominant language
- C++
- Stars
- 117k
- Forks
- 26.8k
- PR merge metrics
- PR metrics pending
Description
### Tested versions
- Reproducible in 4.3-stable
### System information
MacOS Sonoma 14.4.1 (MacBook Pro M1)
### Issue description
The issue in #81526 hasn't been resolved, even though the supposed fix is part of 4.3. In summary, if an inherited scene with an extended script declares more than one typed array as an exported variable, the resulting `.tscn` file will incorrectly type all of the arrays to match the first one that was declared.
### Steps to reproduce
The MRP consists of two minimal scenes (one Node2D and nothing else): `foo.tscn` and `bar.tscn`. `bar.tscn` inherits from `foo.tscn` and has the following script:
```python
extends "res://foo.gd"
@export var bool_array: Array[bool] = []
@export var str_array: Array[String] = []
```
This causes `bar.tscn` to incorrectly save `str_array` as an array of `bool`, as can be seen here:
If you change the order of the declarations and save the scene again, then both will be typed as `Array[String]` in `bar.tscn`.
I think it's also relevant to mention that non-inherited scenes don't even save empty arrays to the `.tscn` file.
**UPDATE Nº 1**: It's not even necessary for `bar.gd` to extend `foo.gd` for the bug to surface. Scene inheritance is enough
**UPDATE Nº2**: If you remove the script attached to `foo.tscn`, the issue goes away. The empty arrays are not even saved in `bar.tscn`. The issue only seems to affect scenes that inherit from another scene and override or extend an existing script
### Minimal reproduction project (MRP)
[array-repro.zip](https://github.com/user-attachments/files/18301829/array-repro.zip)
Contributor guide
Research direction
Start by opening the attached array-repro.zip and reproducing the issue with foo.tscn, bar.tscn, and the extended script declarations. Compare the generated bar.tscn after changing declaration order and after removing the base script. Done means inherited scenes preserve each exported array's declared type without incorrectly typing other arrays.
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
- Mostly clear
- Newbie friendliness
- 35/100