### 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)

if (has_expected_type && expected_type.is_hard_type() && expected_type.kind == GDScriptParser::DataType::BUILTIN && expected_type.builtin_type == Variant::NIL) {
			push_error("A void function cannot return a value.", p_return);
		}
		result = p_return->return_value->get_datatype();
	} else {
		
		result.type_source = GDScriptParser::DataType::ANNOTATED_EXPLICIT;
		result.kind = GDScriptParser::DataType::BUILTIN;
		result.builtin_type = Variant::NIL;
		result.is_constant = true;
	}
	if (has_expected_type) {
		expected_type.is_meta_type = false;
		if (expected_type.is_hard_type()) {
			if (!is_type_compatible(expected_type, result)) {
				
				if (!is_type_compatible(result, expected_type)) {
					push_error(vformat(R"(Cannot return value of type "%s" because the function return type is "%s".)", result.to_string(), expected_type.to_string()), p_return);
				} else {
					
					mark_node_unsafe(p_return);
				}
#ifdef DEBUG_ENABLED
			} else if (expected_type.builtin_type == Variant::INT && result.builtin_type == Variant::FLOAT) {
				parser->push_warning(p_return, GDScriptWarning::NARROWING_CONVERSION);
			} else if (result.is_variant()) {
				mark_node_unsafe(p_return);
#endif
			}
		}