### 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 (is_awaited) {
								gen->write_call_async(result, self, call->function_name, arguments);
							} else {
								gen->write_call(result, self, call->function_name, arguments);
							}
						} else {
							if (is_awaited) {
								gen->write_call_self_async(result, call->function_name, arguments);
							} else {
								gen->write_call_self(result, call->function_name, arguments);
							}
						}
					} else if (callee->type == GDScriptParser::Node::SUBSCRIPT) {
						const GDScriptParser::SubscriptNode *subscript = static_cast<const GDScriptParser::SubscriptNode *>(call->callee);
						if (subscript->is_attribute) {
							
							if (!call->is_super && subscript->base->type == GDScriptParser::Node::IDENTIFIER && GDScriptParser::get_builtin_type(static_cast<GDScriptParser::IdentifierNode *>(subscript->base)->name) < Variant::VARIANT_MAX) {
								gen->write_call_builtin_type_static(result, GDScriptParser::get_builtin_type(static_cast<GDScriptParser::IdentifierNode *>(subscript->base)->name), subscript->attribute->name, arguments);
							} else if (!call->is_super && subscript->base->type == GDScriptParser::Node::IDENTIFIER && call->function_name != SNAME("new") &&
									ClassDB::class_exists(static_cast<GDScriptParser::IdentifierNode *>(subscript->base)->name) && !Engine::get_singleton()->has_singleton(static_cast<GDScriptParser::IdentifierNode *>(subscript->base)->name)) {
								
								gen->write_call_native_static(result, static_cast<GDScriptParser::IdentifierNode *>(subscript->base)->name, subscript->attribute->name, arguments);
							} else {
								GDScriptCodeGenerator::Address base = _parse_expression(codegen, r_error, subscript->base);
								if (r_error) {
									return GDScriptCodeGenerator::Address();
								}
								if (is_awaited) {
									gen->write_call_async(result, base, call->function_name, arguments);
								} else if (base.type.has_type && base.type.kind != GDScriptDataType::BUILTIN) {