### Godot version

v4.1.1-stable_mono_win64

### System information

Windows 11

### Issue description

I removed the node to replace it with another, but when I change the path in the code, the engine crashes for me.

### Steps to reproduce

I did a screen recording as it happens:

https://github.com/godotengine/godot/assets/116289408/b2fd2689-8d82-44e8-8e02-be01674842e1



### Minimal reproduction project

[MixApo.zip](https://github.com/godotengine/godot/files/12208403/MixApo.zip)

float o = (float)code_completion_line_ofs / code_completion_options_count;
					draw_rect(Rect2(code_completion_rect.position.x + code_completion_rect.size.width, code_completion_rect.position.y + o * code_completion_rect.size.y, scroll_width, code_completion_rect.size.y * r), scroll_color);
				}
			}
			
			if (caret_visible && !code_hint.is_empty() && (!code_completion_active || (code_completion_below != code_hint_draw_below))) {
				const int font_height = theme_cache.font->get_height(theme_cache.font_size);
				Vector<String> code_hint_lines = code_hint.split("\n");
				int line_count = code_hint_lines.size();
				int max_width = 0;
				for (int i = 0; i < line_count; i++) {
					max_width = MAX(max_width, theme_cache.font->get_string_size(code_hint_lines[i], HORIZONTAL_ALIGNMENT_LEFT, -1, theme_cache.font_size).x);
				}
				Size2 minsize = theme_cache.code_hint_style->get_minimum_size() + Size2(max_width, line_count * font_height + (theme_cache.line_spacing * line_count - 1));
				int offset = theme_cache.font->get_string_size(code_hint_lines[0].substr(0, code_hint_lines[0].find(String::chr(0xFFFF))), HORIZONTAL_ALIGNMENT_LEFT, -1, theme_cache.font_size).x;
				if (code_hint_xpos == -0xFFFF) {
					code_hint_xpos = get_caret_draw_pos().x - offset;
				}
				Point2 hint_ofs = Vector2(code_hint_xpos, get_caret_draw_pos().y);
				if (code_hint_draw_below) {
					hint_ofs.y += theme_cache.line_spacing / 2.0f;
				} else {
					hint_ofs.y -= (minsize.y + row_height) - theme_cache.line_spacing;
				}
				draw_style_box(theme_cache.code_hint_style, Rect2(hint_ofs, minsize));
				int yofs = 0;
				for (int i = 0; i < line_count; i++) {
					const String &line = code_hint_lines[i];
					int begin = 0;
					int end = 0;