Browse Source

GDScript: Show error when function return type is missing

George Marques 5 years ago
parent
commit
846856728b
1 changed files with 3 additions and 0 deletions
  1. 3 0
      modules/gdscript/gdscript_parser.cpp

+ 3 - 0
modules/gdscript/gdscript_parser.cpp

@@ -1149,6 +1149,9 @@ GDScriptParser::FunctionNode *GDScriptParser::parse_function() {
 	if (match(GDScriptTokenizer::Token::FORWARD_ARROW)) {
 		make_completion_context(COMPLETION_TYPE_NAME_OR_VOID, function);
 		function->return_type = parse_type(true);
+		if (function->return_type == nullptr) {
+			push_error(R"(Expected return type or "void" after "->".)");
+		}
 	}
 
 	// TODO: Improve token consumption so it synchronizes to a statement boundary. This way we can get into the function body with unrecognized tokens.