### 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
ERR_FAIL_COND_V_MSG(!valid_annotations.has(p_annotation->name), false, vformat(R"(Annotation "%s" not found to validate.)", p_annotation->name));
	const MethodInfo &info = valid_annotations[p_annotation->name].info;
	if (((info.flags & METHOD_FLAG_VARARG) == 0) && p_annotation->arguments.size() > info.arguments.size()) {
		push_error(vformat(R"(Annotation "%s" requires at most %d arguments, but %d were given.)", p_annotation->name, info.arguments.size(), p_annotation->arguments.size()));
		return false;
	}
	if (p_annotation->arguments.size() < info.arguments.size() - info.default_arguments.size()) {
		push_error(vformat(R"(Annotation "%s" requires at least %d arguments, but %d were given.)", p_annotation->name, info.arguments.size() - info.default_arguments.size(), p_annotation->arguments.size()));
		return false;
	}
	
	if (p_annotation->name == SNAME("@icon")) {
		ExpressionNode *argument = p_annotation->arguments[0];
		if (argument->type != Node::LITERAL) {
			push_error(R"(Argument 1 of annotation "@icon" must be a string literal.)", argument);
			return false;
		}
		Variant value = static_cast<LiteralNode *>(argument)->value;
		if (value.get_type() != Variant::STRING) {
			push_error(R"(Argument 1 of annotation "@icon" must be a string literal.)", argument);
			return false;
		}
		p_annotation->resolved_arguments.push_back(value);
	}
	
	return true;
}
bool GDScriptParser::tool_annotation(const AnnotationNode *p_annotation, Node *p_node) {