Patch 9.0.1157
Problem:    "implements" only handles one interface name.
Solution:   Handle a comma separated list of names.  Check for duplicate
            names.
Files:      src/vim9class.c, src/errors.h, src/testdir/test_vim9_class.vim


*** ../vim-9.0.1156/src/vim9class.c     2023-01-07 10:51:26.364797976 +0000
--- src/vim9class.c     2023-01-07 14:25:28.798452964 +0000
***************
*** 245,266 ****
        //    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))
            {
!               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;
!           if (ga_add_string(&ga_impl, iname) == FAIL)
            {
!               vim_free(iname);
!               goto early_ret;
            }
-           arg = skipwhite(impl_end);
        }
        else
        {
--- 245,289 ----
        //    specifies SomeInterface
        if (STRNCMP(arg, "implements", 10) == 0 && IS_WHITE_OR_NUL(arg[10]))
        {
!           if (ga_impl.ga_len > 0)
            {
!               emsg(_(e_duplicate_implements));
                goto early_ret;
            }
!           arg = skipwhite(arg + 10);
! 
!           for (;;)
            {
!               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);
            }
        }
        else
        {
*** ../vim-9.0.1156/src/errors.h        2023-01-06 18:42:16.430674097 +0000
--- src/errors.h        2023-01-07 14:24:33.451009914 +0000
***************
*** 3422,3425 ****
--- 3422,3429 ----
        INIT(= N_("E1348: Member \"%s\" of interface \"%s\" not implemented"));
  EXTERN char e_function_str_of_interface_str_not_implemented[]
        INIT(= N_("E1349: Function \"%s\" of interface \"%s\" not 
implemented"));
+ EXTERN char e_duplicate_implements[]
+       INIT(= N_("E1350: Duplicate \"implements\""));
+ EXTERN char e_duplicate_interface_after_implements_str[]
+       INIT(= N_("E1351: Duplicate interface after \"implements\": %s"));
  #endif
*** ../vim-9.0.1156/src/testdir/test_vim9_class.vim     2023-01-07 
12:08:37.954707527 +0000
--- src/testdir/test_vim9_class.vim     2023-01-07 14:26:12.093982684 +0000
***************
*** 627,637 ****
--- 627,676 ----
            echo nr
          enddef
        endclass
+ 
+       interface Another
+         this.member: string
+       endinterface
+ 
+       class SomeImpl implements Some, Another
+         this.member = 'abc'
+         static count: number
+         def Method(nr: number)
+           echo nr
+         enddef
+       endclass
+ 
    END
    v9.CheckScriptSuccess(lines)
  
    lines =<< trim END
        vim9script
+ 
+       interface Some
+         static counter: number
+       endinterface
+ 
+       class SomeImpl implements Some implements Some
+         static count: number
+       endclass
+   END
+   v9.CheckScriptFailure(lines, 'E1350:')
+ 
+   lines =<< trim END
+       vim9script
+ 
+       interface Some
+         static counter: number
+       endinterface
+ 
+       class SomeImpl implements Some, Some
+         static count: number
+       endclass
+   END
+   v9.CheckScriptFailure(lines, 'E1351: Duplicate interface after 
"implements": Some')
+ 
+   lines =<< trim END
+       vim9script
  
        interface Some
          static counter: number
*** ../vim-9.0.1156/src/version.c       2023-01-07 13:07:06.990558035 +0000
--- src/version.c       2023-01-07 13:57:42.642707677 +0000
***************
*** 697,698 ****
--- 697,700 ----
  {   /* Add new patch number below this line */
+ /**/
+     1157,
  /**/

-- 
ARTHUR: I've said I'm sorry about the old woman, but from the behind you
        looked ...
DENNIS: What I object to is that you automatically treat me like an inferior...
ARTHUR: Well ... I AM king.
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///                                                                      \\\
\\\        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/20230107145135.A77DF1C044B%40moolenaar.net.

Raspunde prin e-mail lui