### Godot version

4.0-rc6

### System information

Fedora 37, Mesa Intel ADL GT2

### Issue description

Code that works as expected at runtime fails with Nil references to (assigned) exported vars in the editor:

![tool_global_position_error](https://user-images.githubusercontent.com/364501/222031460-ffb1ecbd-5175-4a42-8470-25285ba5f821.png)


### Steps to reproduce

Try to access the `global_position` of a `Node3D` that's assigned to an exported var.

See that it works at runtime.

See that it errors in the editor with:

> Invalid get index 'global_position' (on base: 'Nil').

### Minimal reproduction project

[tool_test.zip](https://github.com/godotengine/godot/files/10856640/tool_test.zip)

int prev_expansion_rows = expansion_rows;
			expansion_rows = 0;
			const int bsize = (grid_size.height * 80 / 100) / 2;
			const int h = bsize * 2 + 1;
			Color color = get_theme_color(read_only ? SNAME("disabled_highlight_color") : SNAME("highlight_color"), SNAME("Editor"));
			Color text_color = get_theme_color(read_only ? SNAME("disabled_font_color") : SNAME("font_color"), SNAME("Editor"));
			text_color.a *= 0.5;
			Color text_color_on = get_theme_color(read_only ? SNAME("disabled_font_color") : SNAME("font_hover_color"), SNAME("Editor"));
			text_color_on.a *= 0.7;
			const int vofs = (grid_size.height - h) / 2;
			int layer_index = 0;
			Point2 arrow_pos;
			Point2 block_ofs(4, vofs);
			while (true) {
				Point2 ofs = block_ofs;
				for (int i = 0; i < 2; i++) {
					for (int j = 0; j < layer_group_size; j++) {
						const bool on = value & (1 << layer_index);
						Rect2 rect2 = Rect2(ofs, Size2(bsize, bsize));
						color.a = on ? 0.6 : 0.2;
						if (layer_index == hovered_index) {
							
							color.a += 0.15;
						}
						draw_rect(rect2, color);
						flag_rects.push_back(rect2);
						Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label"));
						int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label"));
						Vector2 offset;
						offset.y = rect2.size.y * 0.75;