### 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 (!cast_type.is_variant()) {
		GDScriptParser::DataType op_type = p_cast->operand->get_datatype();
		if (!op_type.is_variant()) {
			bool valid = false;
			bool more_informative_error = false;
			if (op_type.kind == GDScriptParser::DataType::ENUM && cast_type.kind == GDScriptParser::DataType::ENUM) {
				
				if (p_cast->operand->is_constant && p_cast->operand->reduced) {
					if (enum_get_value_name(cast_type, p_cast->operand->reduced_value) != StringName()) {
						valid = true;
					} else {
						valid = false;
						more_informative_error = true;
						push_error(vformat(R"(Invalid cast. Enum "%s" does not have value corresponding to "%s.%s" (%d).)",
										   cast_type.to_string(), op_type.enum_type,
										   enum_get_value_name(op_type, p_cast->operand->reduced_value), 
										   p_cast->operand->reduced_value.operator uint64_t()),
								p_cast->cast_type);
					}
				} else {
					
					mark_node_unsafe(p_cast);
					valid = true;
				}
			} else if (op_type.kind == GDScriptParser::DataType::BUILTIN && op_type.builtin_type == Variant::INT && cast_type.kind == GDScriptParser::DataType::ENUM) {
				
				if (p_cast->operand->is_constant && p_cast->operand->reduced) {
					if (enum_get_value_name(cast_type, p_cast->operand->reduced_value) != StringName()) {
						valid = true;
					} else {