### Godot version

v4.0custom_build[fcba87e]

### System information

Windows 10

### Issue description

Error when trying to call a method with a ternary operator.

### Steps to reproduce

```
extends Node

func _ready() -> void:
	test() if true else test()

func test() -> void:
	pass
```
[fcba87e](https://github.com/godotengine/godot/commit/fcba87e696d58912838d8a4a6987b10efa28e78f) - `Line 4:Cannot get return value of call to "test()" because it returns "void".`

v4.0beta10 - works fine

### Minimal reproduction project

[ternary_bug.zip](https://github.com/godotengine/godot/files/10368477/ternary_bug.zip)

builtin_types["Signal"] = Variant::SIGNAL;
		builtin_types["Array"] = Variant::ARRAY;
		builtin_types["PackedByteArray"] = Variant::PACKED_BYTE_ARRAY;
		builtin_types["PackedInt32Array"] = Variant::PACKED_INT32_ARRAY;
		builtin_types["PackedInt64Array"] = Variant::PACKED_INT64_ARRAY;
		builtin_types["PackedFloat32Array"] = Variant::PACKED_FLOAT32_ARRAY;
		builtin_types["PackedFloat64Array"] = Variant::PACKED_FLOAT64_ARRAY;
		builtin_types["PackedStringArray"] = Variant::PACKED_STRING_ARRAY;
		builtin_types["PackedVector2Array"] = Variant::PACKED_VECTOR2_ARRAY;
		builtin_types["PackedVector3Array"] = Variant::PACKED_VECTOR3_ARRAY;
		builtin_types["PackedColorArray"] = Variant::PACKED_COLOR_ARRAY;
		
		if (builtin_types.size() != Variant::VARIANT_MAX - 1) {
			ERR_PRINT("Outdated parser: amount of built-in types don't match the amount of types in Variant.");
		}
	}
	if (builtin_types.has(p_type)) {
		return builtin_types[p_type];
	}
	return Variant::VARIANT_MAX;
}
void GDScriptParser::cleanup() {
	builtin_types.clear();
}
void GDScriptParser::get_annotation_list(List<MethodInfo> *r_annotations) const {
	for (const KeyValue<StringName, AnnotationInfo> &E : valid_annotations) {
		r_annotations->push_back(E.value.info);
	}
}
bool GDScriptParser::annotation_exists(const String &p_annotation_name) const {