### Godot version

v4.0.rc.custom_build [b12bf7ff0]

### System information

Ubuntu 23.04 (Lunar Lobster)

### Issue description

In a spatial shader: calling textureSize with a texture with hint_screen_texture or hint_depth_texture causes a long list of errors in the terminal, hangs the editor for a minute and fails to run the shader. Shaders using textureSize built fine two weeks ago.



### Steps to reproduce

Open sample project. Errors should be printed to console right away.

[terminal_output.txt](https://github.com/godotengine/godot/files/10700615/terminal_output.txt)




### Minimal reproduction project

[textureSize.zip](https://github.com/godotengine/godot/files/10700628/textureSize.zip)

Shader for MeshInstance3D with a plane mesh:

```
shader_type spatial;

uniform sampler2D SCREEN_TEXTURE : hint_screen_texture, filter_linear_mipmap;

void fragment() {
    textureSize(SCREEN_TEXTURE, 0);  // <- culprit
    ALBEDO = vec3(1, 0, 0);
}
```
if (p_filter == ShaderLanguage::FILTER_DEFAULT) {
		ERR_FAIL_COND_V(actions.default_filter == ShaderLanguage::FILTER_DEFAULT, String());
		p_filter = actions.default_filter;
	}
	if (p_repeat == ShaderLanguage::REPEAT_DEFAULT) {
		ERR_FAIL_COND_V(actions.default_repeat == ShaderLanguage::REPEAT_DEFAULT, String());
		p_repeat = actions.default_repeat;
	}
	return actions.sampler_array_name + "[" + itos(p_filter + (p_repeat == ShaderLanguage::REPEAT_ENABLE ? ShaderLanguage::FILTER_DEFAULT : 0)) + "]";
}
void ShaderCompiler::_dump_function_deps(const SL::ShaderNode *p_node, const StringName &p_for_func, const HashMap<StringName, String> &p_func_code, String &r_to_add, HashSet<StringName> &added) {
	int fidx = -1;
	for (int i = 0; i < p_node->functions.size(); i++) {
		if (p_node->functions[i].name == p_for_func) {
			fidx = i;
			break;
		}
	}
	ERR_FAIL_COND(fidx == -1);
	Vector<StringName> uses_functions;
	for (const StringName &E : p_node->functions[fidx].uses_function) {
		uses_functions.push_back(E);
	}
	uses_functions.sort_custom<StringName::AlphCompare>(); 
	for (int k = 0; k < uses_functions.size(); k++) {
		if (added.has(uses_functions[k])) {
			continue; 
		}
		_dump_function_deps(p_node, uses_functions[k], p_func_code, r_to_add, added);
		SL::FunctionNode *fnode = nullptr;