### Godot version

4.0 beta 10

### System information

Windows 10

### Issue description

Godot crashes when i accidently name 2 items in an enum the same

EDIT:
The editor freeze for some seconds, then both editor- and console-window dissapear

### Steps to reproduce

Write

```gdscript
enum {
    A,
}
```

and then add a second line with another A:

```gdscript
enum {
    A,
    A # <- crash
}
```

Does not always immediatly happen if i copy&paste items.
Does not happen when i change the script in another editor and open the script in Godot.

### Minimal reproduction project

[enum.zip](https://github.com/godotengine/godot/files/10313759/enum.zip)

String path = ScriptServer::get_global_class_path(first);
			String ext = path.get_extension();
			if (ext == GDScriptLanguage::get_singleton()->get_extension()) {
				Ref<GDScriptParserRef> ref = get_parser_for(path);
				if (!ref.is_valid() || ref->raise_status(GDScriptParserRef::INHERITANCE_SOLVED) != OK) {
					push_error(vformat(R"(Could not parse global class "%s" from "%s".)", first, ScriptServer::get_global_class_path(first)), p_type);
					return bad_type;
				}
				result = ref->get_parser()->head->get_datatype();
			} else {
				result = make_script_meta_type(ResourceLoader::load(path, "Script"));
			}
		}
	} else if (ProjectSettings::get_singleton()->has_autoload(first) && ProjectSettings::get_singleton()->get_autoload(first).is_singleton) {
		const ProjectSettings::AutoloadInfo &autoload = ProjectSettings::get_singleton()->get_autoload(first);
		Ref<GDScriptParserRef> ref = get_parser_for(autoload.path);
		if (ref->raise_status(GDScriptParserRef::INHERITANCE_SOLVED) != OK) {
			push_error(vformat(R"(Could not parse singleton "%s" from "%s".)", first, autoload.path), p_type);
			return bad_type;
		}
		result = ref->get_parser()->head->get_datatype();
	} else if (ClassDB::has_enum(parser->current_class->base_type.native_type, first)) {
		
		result = make_native_enum_type(first, parser->current_class->base_type.native_type);
	} else {
		
		List<GDScriptParser::ClassNode *> script_classes;
		bool found = false;
		get_class_node_current_scope_classes(parser->current_class, &script_classes);
		for (GDScriptParser::ClassNode *script_class : script_classes) {