### Godot version

4.2 (c5da2e54fe50cad34b5f93fa10538978b33af88d)

### System information

Windows 11

### Issue description

Attempting to run a scene with the following script report Identifier not found error:

![image](https://github.com/godotengine/godot/assets/3036176/3a63b930-0588-499d-80a2-4f88f5f07116)

This does not happen on 4.1.1 so this is a regression.

### Steps to reproduce

Create a script derived from Control and try to get access to the mouse_entered signal.

### Minimal reproduction project

[TestBug.zip](https://github.com/godotengine/godot/files/12237764/TestBug.zip)

res = GDScriptCache::get_full_script(global_class_path, err);
								if (err != OK) {
									_set_error("Can't load global class " + String(identifier), p_expression);
									r_error = ERR_COMPILATION_FAILED;
									return GDScriptCodeGenerator::Address();
								}
							} else {
								res = ResourceLoader::load(global_class_path);
								if (res.is_null()) {
									_set_error("Can't load global class " + String(identifier) + ", cyclic reference?", p_expression);
									r_error = ERR_COMPILATION_FAILED;
									return GDScriptCodeGenerator::Address();
								}
							}
						}
						return codegen.add_constant(res);
					}
#ifdef TOOLS_ENABLED
					if (GDScriptLanguage::get_singleton()->get_named_globals_map().has(identifier)) {
						GDScriptCodeGenerator::Address global = codegen.add_temporary(); 
						gen->write_store_named_global(global, identifier);
						return global;
					}
#endif
				} break;
			}
			
			_set_error("Identifier not found: " + String(identifier), p_expression);
			r_error = ERR_COMPILATION_FAILED;
			return GDScriptCodeGenerator::Address();