Repository: godot
Issue: Parser bug with preloaded particle shader material
Labels: bug,topic:core,needs testing

### Godot version

v4.0.alpha3.official.256069eaf

### System information

Mac OS 12.2.1, AMD Radeon Pro 5500M, Vulkan API 1.1.198

### Issue description

My project fails to load into the editor, exiting with the following error:

```
ERROR: Parser bug (please report): Trying to check compatibility of unset value type
   at: is_type_compatible (modules/gdscript/gdscript_analyzer.cpp:3879)
SCRIPT ERROR: Parse Error: Could not preload resource file "res://Shaders/ParticleDuplicatorWithOffset.tres".
          at: GDScript::reload (res://Scripts/Honeycomb.gd:14)
ERROR: Method/function failed. Returning: ERR_PARSE_ERROR
   at: reload (modules/gdscript/gdscript.cpp:874)
ERROR: res://Main.tscn:35 - Parse Error: [ext_resource] referenced non-loaded resource at: res://Shaders/ParticleDuplicatorWithOffset.tres
   at: _parse_ext_resource (scene/resources/resource_format_text.cpp:170)
ERROR: res://Main.tscn:35 - Parse Error: [ext_resource] referenced non-loaded resource at: res://Shaders/ParticleDuplicatorWithOffset.tres
   at: _parse_node_tag (scene/resources/resource_format_text.cpp:269)
ERROR: Failed loading resource: res://Main.tscn. Make sure resources have been imported by opening the project in the editor at least once.
   at: _load (core/io/resource_loader.cpp:206)
ERROR: Index p_idx = 1 is out of bounds (edited_scene.size() = 1).
   at: remove_scene (editor/editor_data.cpp:569)
ERROR: Attempted to free invalid ID: 0
   at: _free_internal (drivers/vulkan/rendering_device_vulkan.cpp:8410)
ERROR: Attempted to free invalid ID: 0
   at: _free_internal (drivers/vulkan/rendering_device_vulkan.cpp:8410)
ERROR: Attempted to free invalid ID: 0
   at: _free_internal (drivers/vulkan/rendering_device_vulkan.cpp:8410)
ERROR: Attempted to free invalid ID: 0
   at: _free_internal (drivers/vulkan/rendering_device_vulkan.cpp:8410)
ERROR: Attempted to free invalid ID: 0
   at: _free_internal (drivers/vulkan/rendering_device_vulkan.cpp:8410)
ERROR: 1 shaders of type BokehDofRasterShaderRD were never freed
   at: ~ShaderRD (servers/rendering/renderer_rd/shader_rd.cpp:702)
WARNING: 1 RID of type "Framebuffer" was leaked.
     at: _free_rids (drivers/vulkan/rendering_device_vulkan.cpp:8954)
WARNING: 4 RIDs of type "Texture" were leaked.
     at: finalize (drivers/vulkan/rendering_device_vulkan.cpp:9260)
```

this project was saved from the editor. Removing the references to the "res://Shaders/ParticleDuplicatorWithOffset.tres" in the Main.tsc allows it to load again. Reapplying it in the editor runs and saves fine, but again will fail with the same error when reloaded.

 * ParticleDuplicatorWithOffset.tres is a ShaderMaterial.
 * It is attached to a GPUParticle3D in Main.tscn
 * When attached in the editor, it runs fine.
 * Before it was exported as a .tres (when it was a local resource), it loaded in the editor fine.
 * The .tres is also preloaded by res://Scripts/Honeycomb.gd, attached to another node in the scene, with typing as a ShaderMaterial (where Main.tscn just references it as a Material). If I comment out the preloaded variable, the project will load again.
 * All of the following are in a subfolder of the main project: the .gd script with the preload, the .gdshader, and the .tres for the ShaderMaterial


### Steps to reproduce

I don't know how to reproduce it outside of my project. Rebuilding a minimal scene with all of the above mentioned attributes seems to load and save fine.

### Minimal reproduction project

The following loads, but it is an attempt to build a minimal project that exhibits the error (without success):

[G4a3-PreloadParticleShaderMaterial.zip](https://github.com/godotengine/godot/files/8190846/G4a3-PreloadParticleShaderMaterial.zip)

I am happy to work with someone in an attempt to find a project structure that actually saves in the editor, but crashes upon loading.