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

if (valid) {
				p_subscript->is_constant = true;
				p_subscript->reduced_value = value;
				result_type = type_from_variant(value, p_subscript);
			}
		} else if (base_type.is_variant() || !base_type.is_hard_type()) {
			valid = !base_type.is_pseudo_type || p_can_be_pseudo_type;
			result_type.kind = GDScriptParser::DataType::VARIANT;
			if (base_type.is_variant() && base_type.is_hard_type() && base_type.is_meta_type && base_type.is_pseudo_type) {
				
				String enum_name;
				if (p_subscript->base->type == GDScriptParser::Node::IDENTIFIER) {
					enum_name = String(static_cast<GDScriptParser::IdentifierNode *>(p_subscript->base)->name) + ENUM_SEPARATOR + String(p_subscript->attribute->name);
				}
				if (CoreConstants::is_global_enum(enum_name)) {
					result_type = make_global_enum_type(enum_name, StringName());
				} else {
					valid = false;
					mark_node_unsafe(p_subscript);
				}
			} else {
				mark_node_unsafe(p_subscript);
			}
		} else {
			reduce_identifier_from_base(p_subscript->attribute, &base_type);
			GDScriptParser::DataType attr_type = p_subscript->attribute->get_datatype();
			if (attr_type.is_set()) {
				valid = !attr_type.is_pseudo_type || p_can_be_pseudo_type;
				result_type = attr_type;
				p_subscript->is_constant = p_subscript->attribute->is_constant;