### Godot version

v4.0.2.stable.custom_build (nixpkgs version)

### System information

NixOS

### Issue description

The [docs](https://docs.godotengine.org/en/latest/tutorials/scripting/gdscript/gdscript_basics.html#variables) seem to specify that uninitialized variables are null (as noted in this comment on the related issue: https://github.com/godotengine/godot/issues/56223#issuecomment-1175794500):
`var a # Data type is 'null' by default.`

This isn't always the case inside branches within loops. Instead, the variables can take on values from other branches.

### Related
- https://github.com/godotengine/godot/issues/56223

### Steps to reproduce

```
@tool
extends EditorScript

func _run():
	for i in 5:
		if i % 2:
			var j = i
			print("i = %s, j = %s" % [i, j])
		else:
			var k
			print("i = %s, k = %s" % [i, k])
```

Running this prints:
```
i = 0, k = <null>
i = 1, j = 1
i = 2, k = 1
i = 3, j = 3
i = 4, k = 3
```

This version also gives the exact same result:
```
@tool
extends EditorScript

func _run():
	for i in 5:
		match i % 2:
			1:
				var j = i
				print("i = %s, j = %s" % [i, j])
			0:
				var k
				print("i = %s, k = %s" % [i, k])
```

In addition, behavior similar to that described in https://github.com/godotengine/godot/issues/56223#issuecomment-1000996579 can still be reproduced as follows:
```
@tool
extends EditorScript

func _run():
	for i in 3:
		if i % 2:
			for j in range(1, 6, 3):
				pass
			print("i = %s" % i)
		else:
			var k
			var l
			var m
			print("i = %s, k = %s, l = %s, m = %s" % [i, k, l, m])
```
Which prints:
```
i = 0, k = <null>, l = <null>, m = <null>
i = 1
i = 2, k = 4, l = 7, m = (1, 6, 3)
```

### Minimal reproduction project

N/A
hint_prefix += "/" + itos(variable->export_info.hint);
			}
			variable->export_info.hint = PROPERTY_HINT_TYPE_STRING;
			variable->export_info.hint_string = hint_prefix + ":" + variable->export_info.hint_string;
			variable->export_info.type = Variant::ARRAY;
		}
	} else if (p_annotation->name == SNAME("@export_enum")) {
		Variant::Type enum_type = Variant::INT;
		if (export_type.kind == DataType::BUILTIN && export_type.builtin_type == Variant::STRING) {
			enum_type = Variant::STRING;
		} else if (export_type.is_variant() && variable->initializer != nullptr) {
			DataType initializer_type = variable->initializer->get_datatype();
			if (initializer_type.kind == DataType::BUILTIN && initializer_type.builtin_type == Variant::STRING) {
				enum_type = Variant::STRING;
			}
		}
		variable->export_info.type = enum_type;
		if (!export_type.is_variant() && (export_type.kind != DataType::BUILTIN || export_type.builtin_type != enum_type)) {
			push_error(vformat(R"("@export_enum" annotation requires a variable of type "int" or "String" but type "%s" was given instead.)", export_type.to_string()), variable);
			return false;
		}
	} else {
		
		if (!export_type.is_variant() && (export_type.kind != DataType::BUILTIN || export_type.builtin_type != t_type)) {
			
			if ((t_type != Variant::FLOAT || export_type.builtin_type != Variant::INT) && (t_type != Variant::INT || export_type.builtin_type != Variant::FLOAT)) {
				push_error(vformat(R"("%s" annotation requires a variable of type "%s" but type "%s" was given instead.)", p_annotation->name.operator String(), Variant::get_type_name(t_type), export_type.to_string()), variable);
				return false;
			}
		}