### Godot version

v4.2.dev3.mono.official [013e8e3af]

### System information

Windows 11 - Godot 4.2.dev3.mono, Vulkan API 1.3.242 - Forward+ dedicated NVIDIA

### Issue description

Adding a new built-in script to a node and while defining new variables in the script before saving the scene or the node/script, Godot will freeze momentarily after a couple of seconds then exit with the error:

ERROR: FATAL: Index p_index = 0 is out of bounds (size() = 0).
   at: operator[] (./core/templates/list.h:521)

If the scene was saved before editing the script Godot does not crash.
If I edit the script anywhere other than the area for defining variables after the `extends xxx` and before the `func _ready()`, Godot does not crash whether the scene was saved or not.
Defining any kind of variable, whether `@export`, `const`, or `var` causes the crash.
If a normal (not built-in) script was added, Godot does not crash, whether the script was saved before editing or not.

### Steps to reproduce

1. Create a new scene.
2. Add a new script to the root node, either from the "Attach new script" button in the scene hierarchy, or by choosing "New Script" from the drop-down in front of "Script" in the inspector under "Node" section.
3. Check the "Built-in Script" option and click the "Create" button. Giving a name has no change on the  crash behavior.
4. Try adding a new variable definition after the `extends` line.
5. Godot will crash while typing the variable definition line.

### Minimal reproduction project

Unable to provide one, since Godot crashes because the scene and script crashes before they can be saved. The steps to reproduce the crash are already trivial and don't require much setting up.
errors_panel->set_h_size_flags(SIZE_EXPAND_FILL);
	errors_panel->set_meta_underline(true);
	errors_panel->set_selection_enabled(true);
	errors_panel->set_context_menu_enabled(true);
	errors_panel->set_focus_mode(FOCUS_CLICK);
	errors_panel->hide();
	update_settings();
	code_editor->get_text_editor()->set_code_hint_draw_below(EDITOR_GET("text_editor/completion/put_callhint_tooltip_below_current_line"));
	code_editor->get_text_editor()->set_symbol_lookup_on_click_enabled(true);
	code_editor->get_text_editor()->set_context_menu_enabled(false);
	context_menu = memnew(PopupMenu);
	color_panel = memnew(PopupPanel);
	edit_hb = memnew(HBoxContainer);
	edit_menu = memnew(MenuButton);
	edit_menu->set_text(TTR("Edit"));
	edit_menu->set_switch_on_hover(true);
	edit_menu->set_shortcut_context(this);
	highlighter_menu = memnew(PopupMenu);
	highlighter_menu->set_name("highlighter_menu");
	Ref<EditorPlainTextSyntaxHighlighter> plain_highlighter;
	plain_highlighter.instantiate();
	add_syntax_highlighter(plain_highlighter);
	Ref<EditorStandardSyntaxHighlighter> highlighter;
	highlighter.instantiate();
	add_syntax_highlighter(highlighter);
	set_syntax_highlighter(highlighter);
	search_menu = memnew(MenuButton);
	search_menu->set_text(TTR("Search"));
	search_menu->set_switch_on_hover(true);
	search_menu->set_shortcut_context(this);