patch 9.0.1945: Vim9: missing support for ro-vars in interface

Problem:  Vim9: missing support for ro-vars in interface
Solution: Support only read-only object variables in an interface,
          add additional checks when parsing class definitions.

closes: #13183
cloess: #13184
cloess: #13185.
closes: #13188

Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
diff --git a/src/vim9class.c b/src/vim9class.c
index b5e11ca..8b07d76 100644
--- a/src/vim9class.c
+++ b/src/vim9class.c
@@ -1430,11 +1430,19 @@
 	    {
 		char_u *impl_end = find_name_end(arg, NULL, NULL,
 							      FNE_CHECK_START);
-		if (!IS_WHITE_OR_NUL(*impl_end) && *impl_end != ',')
+		if ((!IS_WHITE_OR_NUL(*impl_end) && *impl_end != ',')
+			|| (*impl_end == ','
+			    && !IS_WHITE_OR_NUL(*(impl_end + 1))))
 		{
 		    semsg(_(e_white_space_required_after_name_str), arg);
 		    goto early_ret;
 		}
+		if (impl_end - arg == 0)
+		{
+		    emsg(_(e_missing_name_after_implements));
+		    goto early_ret;
+		}
+
 		char_u *iname = vim_strnsave(arg, impl_end - arg);
 		if (iname == NULL)
 		    goto early_ret;
@@ -1539,6 +1547,11 @@
 		semsg(_(e_command_cannot_be_shortened_str), line);
 		break;
 	    }
+	    if (!is_class)
+	    {
+		emsg(_(e_public_member_not_supported_in_interface));
+		break;
+	    }
 	    has_public = TRUE;
 	    p = skipwhite(line + 6);
 
@@ -1664,7 +1677,20 @@
 	    exarg_T	ea;
 	    garray_T	lines_to_free;
 
-	    // TODO: error for "public static def Func()"?
+	    if (has_public)
+	    {
+		// "public" keyword is not supported when defining an object or
+		// class method
+		emsg(_(e_public_keyword_not_supported_for_method));
+		break;
+	    }
+
+	    if (*p == NUL)
+	    {
+		// No method name following def
+		semsg(_(e_not_valid_command_in_class_str), line);
+		break;
+	    }
 
 	    CLEAR_FIELD(ea);
 	    ea.cmd = line;