### Godot version

v4.0.3.stable.official [5222a99f5]
Master [6101240231600c871f5c5473872532c68ea3268c] (confirmed by https://github.com/godotengine/godot/issues/77666#issuecomment-1568952502)

### System information

Window 10

### Issue description

References are not unreferenced at the end of `if` scopes.

### Steps to reproduce

Copy, paste and run the snippet below, check the results:

```gdscript
extends Node


func _ready() -> void:
  var ref := RefCounted.new()
  var ref_count : int

  # OK
  ref_count = ref.get_reference_count()
  print('Expected: 1, Result: %d' % ref_count)

  # OK
  if true:
    var temp := ref
    temp = null

  ref_count = ref.get_reference_count()
  print('Expected: 1, Result: %d' % ref_count)

  # FAIL
  if true:
    var temp := ref

  ref_count = ref.get_reference_count()
  print('Expected: 1, Result: %d' % ref_count)
```

Output example:

```
Expected: 1, Result: 1
Expected: 1, Result: 1
Expected: 1, Result: 2
```

### Minimal reproduction project

N/A
if (class_name != StringName() && native_base != StringName() && ClassDB::is_parent_class(native_base, SNAME("Resource"))) {
					variable->export_info.type = Variant::OBJECT;
					variable->export_info.hint = PROPERTY_HINT_RESOURCE_TYPE;
					variable->export_info.hint_string = class_name;
				}
			} break;
			case GDScriptParser::DataType::ENUM: {
				variable->export_info.type = Variant::INT;
				variable->export_info.hint = PROPERTY_HINT_ENUM;
				String enum_hint_string;
				bool first = true;
				for (const KeyValue<StringName, int64_t> &E : export_type.enum_values) {
					if (!first) {
						enum_hint_string += ",";
					} else {
						first = false;
					}
					enum_hint_string += E.key.operator String().capitalize().xml_escape();
					enum_hint_string += ":";
					enum_hint_string += String::num_int64(E.value).xml_escape();
				}
				variable->export_info.hint_string = enum_hint_string;
			} break;
			default:
				push_error(R"(Export type can only be built-in, a resource, a node, or an enum.)", variable);
				break;
		}
		if (is_array) {
			String hint_prefix = itos(variable->export_info.type);
			if (variable->export_info.hint) {