diff options
Diffstat (limited to 'src/vim9class.c')
-rw-r--r-- | src/vim9class.c | 45 |
1 files changed, 34 insertions, 11 deletions
diff --git a/src/vim9class.c b/src/vim9class.c index 92e3c6316b..4a8dd7c0ef 100644 --- a/src/vim9class.c +++ b/src/vim9class.c @@ -245,22 +245,45 @@ ex_class(exarg_T *eap) // specifies SomeInterface if (STRNCMP(arg, "implements", 10) == 0 && IS_WHITE_OR_NUL(arg[10])) { - arg = skipwhite(arg + 10); - char_u *impl_end = find_name_end(arg, NULL, NULL, FNE_CHECK_START); - if (!IS_WHITE_OR_NUL(*impl_end)) + if (ga_impl.ga_len > 0) { - semsg(_(e_white_space_required_after_name_str), arg); + emsg(_(e_duplicate_implements)); goto early_ret; } - char_u *iname = vim_strnsave(arg, impl_end - arg); - if (iname == NULL) - goto early_ret; - if (ga_add_string(&ga_impl, iname) == FAIL) + arg = skipwhite(arg + 10); + + for (;;) { - vim_free(iname); - goto early_ret; + char_u *impl_end = find_name_end(arg, NULL, NULL, + FNE_CHECK_START); + if (!IS_WHITE_OR_NUL(*impl_end) && *impl_end != ',') + { + semsg(_(e_white_space_required_after_name_str), arg); + goto early_ret; + } + char_u *iname = vim_strnsave(arg, impl_end - arg); + if (iname == NULL) + goto early_ret; + for (int i = 0; i < ga_impl.ga_len; ++i) + if (STRCMP(((char_u **)ga_impl.ga_data)[i], iname) == 0) + { + semsg(_(e_duplicate_interface_after_implements_str), + iname); + vim_free(iname); + goto early_ret; + } + if (ga_add_string(&ga_impl, iname) == FAIL) + { + vim_free(iname); + goto early_ret; + } + if (*impl_end != ',') + { + arg = skipwhite(impl_end); + break; + } + arg = skipwhite(impl_end + 1); } - arg = skipwhite(impl_end); } else { |