Godot Engine – Multi-platform 2D and 3D game engine
GDScript: Make range for "not all code paths" error span return type
Malcolm Andersoned5067022aab
diff --git a/modules/gdscript/gdscript_analyzer.cpp b/modules/gdscript/gdscript_analyzer.cppindex 3a0335cb6e7..e8f7d42b37a 100644--- a/modules/gdscript/gdscript_analyzer.cpp+++ b/modules/gdscript/gdscript_analyzer.cpp@@ -2052,7 +2052,7 @@ void GDScriptAnalyzer::resolve_function_body(GDScriptParser::FunctionNode *p_funp_function->return_type_constraint = p_function->body->suite_type;} else if (p_function->return_type_constraint.is_hard_type() && (p_function->return_type_constraint.kind != GDScriptParser::DataType::BUILTIN || p_function->return_type_constraint.builtin_type != Variant::NIL)) {if (!p_function->body->has_return && (p_is_lambda || p_function->identifier->name != GDScriptLanguage::get_singleton()->strings._init)) {- push_error(R"(Not all code paths return a value.)", p_function);+ push_error(R"(Not all code paths return a value.)", p_function->return_type ? static_cast<GDScriptParser::Node *>(p_function->return_type) : static_cast<GDScriptParser::Node *>(p_function));}}diff --git a/modules/gdscript/gdscript_parser.cpp b/modules/gdscript/gdscript_parser.cppindex b0b878a7826..c5c8fedf897 100644--- a/modules/gdscript/gdscript_parser.cpp+++ b/modules/gdscript/gdscript_parser.cpp@@ -3844,6 +3844,7 @@ GDScriptParser::ExpressionNode *GDScriptParser::parse_invalid_token(ExpressionNoGDScriptParser::TypeNode *GDScriptParser::parse_type(bool p_allow_void) {TypeNode *type = alloc_node<TypeNode>();+ reset_extents(type, current);make_completion_context(p_allow_void ? COMPLETION_TYPE_NAME_OR_VOID : COMPLETION_TYPE_NAME, type);if (!match(GDScriptTokenizer::Token::IDENTIFIER)) {if (match(GDScriptTokenizer::Token::TK_VOID)) {