### 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(p_source == nullptr);
	if (is_ignoring_warnings) {
		return;
	}
	if (GLOBAL_GET("debug/gdscript/warnings/exclude_addons").booleanize() && script_path.begins_with("res://addons/")) {
		return;
	}
	if (ignored_warnings.has(p_code)) {
		return;
	}
	int warn_level = (int)GLOBAL_GET(GDScriptWarning::get_settings_path_from_code(p_code));
	if (!warn_level) {
		return;
	}
	GDScriptWarning warning;
	warning.code = p_code;
	warning.symbols = p_symbols;
	warning.start_line = p_source->start_line;
	warning.end_line = p_source->end_line;
	warning.leftmost_column = p_source->leftmost_column;
	warning.rightmost_column = p_source->rightmost_column;
	if (warn_level == GDScriptWarning::WarnLevel::ERROR) {
		push_error(warning.get_message() + String(" (Warning treated as error.)"), p_source);
		return;
	}
	List<GDScriptWarning>::Element *before = nullptr;
	for (List<GDScriptWarning>::Element *E = warnings.front(); E; E = E->next()) {