### 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)

draw_string(font, rect2.position + offset, itos(layer_index + 1), HORIZONTAL_ALIGNMENT_CENTER, rect2.size.x, font_size, on ? text_color_on : text_color);
						ofs.x += bsize + 1;
						++layer_index;
					}
					ofs.x = block_ofs.x;
					ofs.y += bsize + 1;
				}
				if (layer_index >= layer_count) {
					if (!flag_rects.is_empty() && (expansion_rows == 0)) {
						const Rect2 &last_rect = flag_rects[flag_rects.size() - 1];
						arrow_pos = last_rect.get_end();
					}
					break;
				}
				int block_size_x = layer_group_size * (bsize + 1);
				block_ofs.x += block_size_x + 3;
				if (block_ofs.x + block_size_x + 12 > grid_size.width) {
					
					if (!flag_rects.is_empty() && (expansion_rows == 0)) {
						const Rect2 &last_rect = flag_rects[flag_rects.size() - 1];
						arrow_pos = last_rect.get_end();
					}
					++expansion_rows;
					if (expanded) {
						
						block_ofs.x = 4;
						block_ofs.y += 2 * (bsize + 1) + 3;
					} else {
						
						break;