### 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);
}
```
String id = "m_" + p_id.replace("__", "_dus_");
	return id.replace("__", "_dus_"); 
}
static String f2sp0(float p_float) {
	String num = rtoss(p_float);
	if (!num.contains(".") && !num.contains("e")) {
		num += ".0";
	}
	return num;
}
static String get_constant_text(SL::DataType p_type, const Vector<SL::ConstantNode::Value> &p_values) {
	switch (p_type) {
		case SL::TYPE_BOOL:
			return p_values[0].boolean ? "true" : "false";
		case SL::TYPE_BVEC2:
		case SL::TYPE_BVEC3:
		case SL::TYPE_BVEC4: {
			String text = "bvec" + itos(p_type - SL::TYPE_BOOL + 1) + "(";
			for (int i = 0; i < p_values.size(); i++) {
				if (i > 0) {
					text += ",";
				}
				text += p_values[i].boolean ? "true" : "false";
			}
			text += ")";
			return text;
		}
		case SL::TYPE_INT:
			return itos(p_values[0].sint);
		case SL::TYPE_IVEC2: