0
0
mirror of https://github.com/vim/vim.git synced 2025-09-25 03:54:15 -04:00

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>
This commit is contained in:
Yegappan Lakshmanan
2023-09-27 19:02:01 +02:00
committed by Christian Brabandt
parent 5277cfaf8a
commit 2dede3dbfa
8 changed files with 190 additions and 102 deletions

View File

@@ -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;