### 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 (path_state != PATH_STATE_START && path_state != PATH_STATE_SLASH) {
				push_error(R"("%" is only valid in the beginning of a node name (either after "$" or after "/"))");
				complete_extents(get_node);
				return nullptr;
			}
			get_node->full_path += "%";
			path_state = PATH_STATE_PERCENT;
		} else if (previous.type == GDScriptTokenizer::Token::SLASH) {
			if (path_state != PATH_STATE_START && path_state != PATH_STATE_NODE_NAME) {
				push_error(R"("/" is only valid at the beginning of the path or after a node name.)");
				complete_extents(get_node);
				return nullptr;
			}
			get_node->full_path += "/";
			path_state = PATH_STATE_SLASH;
		}
		make_completion_context(COMPLETION_GET_NODE, get_node, context_argument++);
		if (match(GDScriptTokenizer::Token::LITERAL)) {
			if (previous.literal.get_type() != Variant::STRING) {
				String previous_token;
				switch (path_state) {
					case PATH_STATE_START:
						previous_token = "$";
						break;
					case PATH_STATE_PERCENT:
						previous_token = "%";
						break;
					case PATH_STATE_SLASH:
						previous_token = "/";
						break;