Mercurial > vim
diff src/vim9class.c @ 33372:3e9a91624b40 v9.0.1945
patch 9.0.1945: Vim9: missing support for ro-vars in interface
Commit: https://github.com/vim/vim/commit/2dede3dbfa3cb52f464f942d46d3ec0f66e3e354
Author: Yegappan Lakshmanan <yegappan@yahoo.com>
Date: Wed Sep 27 19:02:01 2023 +0200
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>
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Wed, 27 Sep 2023 19:15:04 +0200 |
parents | 41b50abddeea |
children | 17301c641749 |
line wrap: on
line diff
--- a/src/vim9class.c +++ b/src/vim9class.c @@ -1430,11 +1430,19 @@ ex_class(exarg_T *eap) { 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 @@ early_ret: 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 @@ early_ret: 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;