godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
89.88k stars 21.03k forks source link

Exported Node Array loses its contents if scene is reloaded during invalid script #96715

Open RedMser opened 4 weeks ago

RedMser commented 4 weeks ago

Tested versions

Reproduced in 4.3-stable

System information

Godot v4.3.stable - Windows 10.0.19044 - GLES3 (Compatibility) - NVIDIA GeForce RTX 2080 (NVIDIA; 32.0.15.5585) - Intel(R) Core(TM) i7-8700K CPU @ 3.70GHz (12 Threads)

Issue description

If a script exports an Array[Node], its contents will be lost if the script has an error and the scene file is reloaded in the editor. This can also happen when using external editor to write the script, but is likely the same issue.

I also tried the same with float and Array[int], but everything gets remembered properly in these cases.

https://github.com/user-attachments/assets/9ac089d0-a795-4d44-8df3-0e335e62a169

Steps to reproduce

If you download the MRP, you can skip step 1 and 2.

  1. Create a script with @export var breaks: Array[Node] = [] in it.
  2. Assign script to a node in scene, give the array contents, save the scene.
  3. Introduce a parse error into the script (e.g. add func to the end of the file) and save.
  4. Reload the scene using "Scene -> Reload Saved Scene".
  5. Remove the error introduced in 3. and observe the exported node array being empty now.

Minimal reproduction project (MRP)

node-array-scene-restore.zip

matheusmdx commented 3 weeks ago

Bisecting points to #78240 as the culprit, @KoBeWi

image

KoBeWi commented 2 weeks ago

Well reverting #78240 makes it work correctly. I tried to test whether it brings back #78238, but I was stopped by this new regression: #97153