### Godot version

4.0.beta17

### System information

windows 10, nvidia graphics

### Issue description

When creating a typed array from another base array, if the base array was gotten from get_tree().get_nodes_in_group(), you cannot create a typed array assigning a script different from null, otherwise the resulting array will be filled with nulls.

![image](https://user-images.githubusercontent.com/5783414/216142311-1eded30c-e8ff-4a2b-aa5a-61ae5cafce13.png)


### Steps to reproduce

See attached video:

https://user-images.githubusercontent.com/5783414/216142187-82af9900-d490-4d6d-b4cc-9d776d8b8cc9.mp4



### Minimal reproduction project

[TypedArrayConstructorDoesntWorkWithScriptsWhenUsingGetNodesInGroup.zip](https://github.com/godotengine/godot/files/10560863/TypedArrayConstructorDoesntWorkWithScriptsWhenUsingGetNodesInGroup.zip)

### WorkAround

Instead of using the output of get_tree().get_nodes_in_group() directly, the user can join it with an empty array
```gdscript
[]+get_tree().get_nodes_in_group()
```
and it will work as expected.
ERR_FAIL_COND_MSG(_p->read_only, "Array is in read-only state.");
	_p->array.sort_custom<CallableComparator, true>(p_callable);
}
void Array::shuffle() {
	ERR_FAIL_COND_MSG(_p->read_only, "Array is in read-only state.");
	const int n = _p->array.size();
	if (n < 2) {
		return;
	}
	Variant *data = _p->array.ptrw();
	for (int i = n - 1; i >= 1; i--) {
		const int j = Math::rand() % (i + 1);
		const Variant tmp = data[j];
		data[j] = data[i];
		data[i] = tmp;
	}
}
int Array::bsearch(const Variant &p_value, bool p_before) const {
	Variant value = p_value;
	ERR_FAIL_COND_V(!_p->typed.validate(value, "binary search"), -1);
	SearchArray<Variant, _ArrayVariantSort> avs;
	return avs.bisect(_p->array.ptrw(), _p->array.size(), value, p_before);
}
int Array::bsearch_custom(const Variant &p_value, const Callable &p_callable, bool p_before) const {
	Variant value = p_value;
	ERR_FAIL_COND_V(!_p->typed.validate(value, "custom binary search"), -1);
	return _p->array.bsearch_custom<CallableComparator>(value, p_before, p_callable);
}
void Array::reverse() {