### Godot version

4.0.2

### System information

Linux Mint 21

### Issue description

On the minimal reproduction project, with a 3 level hierarchy and 2 autoloads, when running the game we get a parse error in daughter.gd where we use a parent member.

**Additional remarks :** 
- We have a circular dependency involving one of the autoloads : Autoload2 references Daughter which references Mother which references GrandMother which references Autoload2
- Autoload1 references Mother which references GrandMother which references Autoload2
- We don't have any error if we switch the 2 autoloads order in Project Settings
- We get the same error if _member is put in GrandMother class instead of Mother class
- We still get the issue if we disable Autoload1 in Project Settings

**A quick look in Godot source code :**
- GDScriptCache::full_gdscript_cache contains invalid scripts (ie script->is_valid() is false)
- I think the engine tries to compile GrandMother, then Daughter (but it fails), then Mother

(This issue might be related to https://github.com/godotengine/godot/issues/75388.)

### Steps to reproduce

To get the parse error :
- Open the minimal reproduction project
- Run the game
You'll get `Parser Error: Identifier not found: _member`.

### Minimal reproduction project

[ParseError_Project.zip](https://github.com/godotengine/godot/files/11725756/ParseError_Project.zip)

#ifdef DEBUG_ENABLED
	List<Ref<GDScript>> scripts;
	{
		MutexLock lock(this->mutex);
		SelfList<GDScript> *elem = script_list.first();
		while (elem) {
			
			if (elem->self()->is_root_script() && elem->self()->get_path().is_resource_file()) {
				scripts.push_back(Ref<GDScript>(elem->self())); 
			}
			elem = elem->next();
		}
	}
	
	HashMap<Ref<GDScript>, HashMap<ObjectID, List<Pair<StringName, Variant>>>> to_reload;
	
	scripts.sort_custom<GDScriptDepSort>(); 
	for (Ref<GDScript> &scr : scripts) {
		bool reload = scr == p_script || to_reload.has(scr->get_base());
		if (!reload) {
			continue;
		}
		to_reload.insert(scr, HashMap<ObjectID, List<Pair<StringName, Variant>>>());
		if (!p_soft_reload) {