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

HashMap<String, Ref<GDScriptParserRef>> depended_parsers;
	const GDScriptParser::EnumNode *current_enum = nullptr;
	List<GDScriptParser::LambdaNode *> lambda_stack;
	
	static _FORCE_INLINE_ bool has_member_name_conflict_in_script_class(const StringName &p_name, const GDScriptParser::ClassNode *p_current_class_node, const GDScriptParser::Node *p_member);
	static _FORCE_INLINE_ bool has_member_name_conflict_in_native_type(const StringName &p_name, const StringName &p_native_type_string);
	Error check_native_member_name_conflict(const StringName &p_member_name, const GDScriptParser::Node *p_member_node, const StringName &p_native_type_string);
	Error check_class_member_name_conflict(const GDScriptParser::ClassNode *p_class_node, const StringName &p_member_name, const GDScriptParser::Node *p_member_node);
	void get_class_node_current_scope_classes(GDScriptParser::ClassNode *p_node, List<GDScriptParser::ClassNode *> *p_list);
	Error resolve_class_inheritance(GDScriptParser::ClassNode *p_class, const GDScriptParser::Node *p_source = nullptr);
	Error resolve_class_inheritance(GDScriptParser::ClassNode *p_class, bool p_recursive);
	GDScriptParser::DataType resolve_datatype(GDScriptParser::TypeNode *p_type);
	void decide_suite_type(GDScriptParser::Node *p_suite, GDScriptParser::Node *p_statement);
	void resolve_annotation(GDScriptParser::AnnotationNode *p_annotation);
	void resolve_class_member(GDScriptParser::ClassNode *p_class, StringName p_name, const GDScriptParser::Node *p_source = nullptr);
	void resolve_class_member(GDScriptParser::ClassNode *p_class, int p_index, const GDScriptParser::Node *p_source = nullptr);
	void resolve_class_interface(GDScriptParser::ClassNode *p_class, const GDScriptParser::Node *p_source = nullptr);
	void resolve_class_interface(GDScriptParser::ClassNode *p_class, bool p_recursive);
	void resolve_class_body(GDScriptParser::ClassNode *p_class, const GDScriptParser::Node *p_source = nullptr);
	void resolve_class_body(GDScriptParser::ClassNode *p_class, bool p_recursive);
	void resolve_function_signature(GDScriptParser::FunctionNode *p_function, const GDScriptParser::Node *p_source = nullptr, bool p_is_lambda = false);
	void resolve_function_body(GDScriptParser::FunctionNode *p_function, bool p_is_lambda = false);
	void resolve_node(GDScriptParser::Node *p_node, bool p_is_root = true);
	void resolve_suite(GDScriptParser::SuiteNode *p_suite);
	void resolve_assignable(GDScriptParser::AssignableNode *p_assignable, const char *p_kind);
	void resolve_variable(GDScriptParser::VariableNode *p_variable, bool p_is_local);
	void resolve_constant(GDScriptParser::ConstantNode *p_constant, bool p_is_local);
	void resolve_parameter(GDScriptParser::ParameterNode *p_parameter);
	void resolve_if(GDScriptParser::IfNode *p_if);
	void resolve_for(GDScriptParser::ForNode *p_for);