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

if (nc && (ClassDB::has_signal(nc->get_name(), identifier) || ClassDB::has_method(nc->get_name(), identifier))) {
						
						GDScriptCodeGenerator::Address temp = codegen.add_temporary(); 
						GDScriptCodeGenerator::Address self(GDScriptCodeGenerator::Address::SELF);
						gen->write_get_named(temp, identifier, self);
						return temp;
					}
				} break;
				case GDScriptParser::IdentifierNode::MEMBER_CONSTANT:
				case GDScriptParser::IdentifierNode::MEMBER_CLASS: {
					
					GDScript *owner = codegen.script;
					while (owner) {
						GDScript *scr = owner;
						GDScriptNativeClass *nc = nullptr;
						while (scr) {
							if (scr->constants.has(identifier)) {
								return codegen.add_constant(scr->constants[identifier]); 
							}
							if (scr->native.is_valid()) {
								nc = scr->native.ptr();
							}
							scr = scr->_base;
						}
						
						if (nc) {
							bool success = false;
							int64_t constant = ClassDB::get_integer_constant(nc->get_name(), identifier, &success);
							if (success) {
								return codegen.add_constant(constant);