### Godot version

v4.0.beta17.official [c40020513]

### System information

Apple M1 Max - macOS Ventura 13.1 (22C65)

### Issue description

I am getting an error due to functions no longer returning the correct typed array, when the function concatenates arrays and returns it.

In other words, the following fails:

```
func add_arrays() -> Array[ClassA]:
	var array_1: Array[ClassA] = []
	var array_2: Array[ClassA] = []
	return array_1 + array_2
```

<img width="864" alt="Screenshot 2023-02-02 at 1 02 53 PM" src="https://user-images.githubusercontent.com/905216/216320503-475bf4a1-353e-455c-87d5-69d036db706c.png">

I'm assuming when concatenating, the typing changes to a generic `Array` now? Just a guess. 

### Steps to reproduce

N/A

### Minimal reproduction project

[Godot Crash Project.zip](https://github.com/godotengine/godot/files/10568780/Godot.Crash.Project.zip)

}
		ERR_FAIL_COND_V_MSG(!parser_ref->get_parser()->has_class(p_class), ERR_PARSE_ERROR, R"(Parser bug: Mismatched external parser.)");
		GDScriptAnalyzer *other_analyzer = parser_ref->get_analyzer();
		GDScriptParser *other_parser = parser_ref->get_parser();
		int error_count = other_parser->errors.size();
		other_analyzer->resolve_class_inheritance(p_class);
		if (other_parser->errors.size() > error_count) {
			push_error(vformat(R"(Could not resolve inheritance for class "%s".)", p_class->fqcn), p_source);
			return ERR_PARSE_ERROR;
		}
		return OK;
	}
	GDScriptParser::ClassNode *previous_class = parser->current_class;
	parser->current_class = p_class;
	if (p_class->identifier) {
		StringName class_name = p_class->identifier->name;
		if (GDScriptParser::get_builtin_type(class_name) < Variant::VARIANT_MAX) {
			push_error(vformat(R"(Class "%s" hides a built-in type.)", class_name), p_class->identifier);
		} else if (class_exists(class_name)) {
			push_error(vformat(R"(Class "%s" hides a native class.)", class_name), p_class->identifier);
		} else if (ScriptServer::is_global_class(class_name) && (ScriptServer::get_global_class_path(class_name) != parser->script_path || p_class != parser->head)) {
			push_error(vformat(R"(Class "%s" hides a global script class.)", class_name), p_class->identifier);
		} else if (ProjectSettings::get_singleton()->has_autoload(class_name) && ProjectSettings::get_singleton()->get_autoload(class_name).is_singleton) {
			push_error(vformat(R"(Class "%s" hides an autoload singleton.)", class_name), p_class->identifier);
		}
	}
	GDScriptParser::DataType resolving_datatype;
	resolving_datatype.kind = GDScriptParser::DataType::RESOLVING;
	p_class->base_type = resolving_datatype;