### 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)

case GDScriptParser::IdentifierNode::UNDEFINED_SOURCE: {
					
					if (GDScriptLanguage::get_singleton()->get_global_map().has(identifier)) {
						
						
						HashMap<StringName, ProjectSettings::AutoloadInfo> autoloads = ProjectSettings::get_singleton()->get_autoload_list();
						if (autoloads.has(identifier) && autoloads[identifier].is_singleton) {
							GDScriptCodeGenerator::Address global = codegen.add_temporary(_gdtype_from_datatype(in->get_datatype(), codegen.script));
							int idx = GDScriptLanguage::get_singleton()->get_global_map()[identifier];
							gen->write_store_global(global, idx);
							return global;
						} else {
							int idx = GDScriptLanguage::get_singleton()->get_global_map()[identifier];
							Variant global = GDScriptLanguage::get_singleton()->get_global_array()[idx];
							return codegen.add_constant(global);
						}
					}
					
					if (ScriptServer::is_global_class(identifier)) {
						const GDScriptParser::ClassNode *class_node = codegen.class_node;
						while (class_node->outer) {
							class_node = class_node->outer;
						}
						Ref<Resource> res;
						if (class_node->identifier && class_node->identifier->name == identifier) {
							res = Ref<GDScript>(main_script);
						} else {
							String global_class_path = ScriptServer::get_global_class_path(identifier);
							if (ResourceLoader::get_resource_type(global_class_path) == "GDScript") {
								Error err = OK;