patch 9.0.2085: Vim9: abstract can be used in interface

Commit: 
https://github.com/vim/vim/commit/2b358adde079d7cc8a7f42fcd5627866641c9a59
Author: Yegappan Lakshmanan <[email protected]>
Date:   Thu Nov 2 20:57:32 2023 +0100

    patch 9.0.2085: Vim9: abstract can be used in interface
    
    Problem:  Vim9: abstract can be used in interface
    Solution: Disallow the use of abstract in an interface
    
    fixes: #13456
    closes: #13464
    
    Signed-off-by: Yegappan Lakshmanan <[email protected]>
    Signed-off-by: Christian Brabandt <[email protected]>

diff --git a/src/errors.h b/src/errors.h
index 26ecf0940..85439ba92 100644
--- a/src/errors.h
+++ b/src/errors.h
@@ -3560,8 +3560,10 @@ EXTERN char e_using_typealias_as_string[]
        INIT(= N_("E1402: Using type alias \"%s\" as a String"));
 EXTERN char e_using_typealias_as_value[]
        INIT(= N_("E1403: Type alias \"%s\" cannot be used as a value"));
+EXTERN char e_abstract_cannot_be_used_in_interface[]
+       INIT(= N_("E1404: Abstract cannot be used in an interface"));
 #endif
-// E1404 - E1499 unused (reserved for Vim9 class support)
+// E1405 - E1499 unused (reserved for Vim9 class support)
 EXTERN char e_cannot_mix_positional_and_non_positional_str[]
        INIT(= N_("E1500: Cannot mix positional and non-positional arguments: 
%s"));
 EXTERN char e_fmt_arg_nr_unused_str[]
diff --git a/src/testdir/test_vim9_class.vim b/src/testdir/test_vim9_class.vim
index b3d984124..1f639e2b3 100644
--- a/src/testdir/test_vim9_class.vim
+++ b/src/testdir/test_vim9_class.vim
@@ -5567,7 +5567,26 @@ def Test_abstract_method()
       enddef
     endclass
   END
-  v9.CheckSourceSuccess(lines)
+  v9.CheckSourceFailure(lines, 'E1404: Abstract cannot be used in an 
interface', 3)
+
+  # Use abstract static method in an interface
+  lines =<< trim END
+    vim9script
+    interface A
+      abstract static def Foo()
+      enddef
+    endinterface
+  END
+  v9.CheckSourceFailure(lines, 'E1404: Abstract cannot be used in an 
interface', 3)
+
+  # Use abstract static variable in an interface
+  lines =<< trim END
+    vim9script
+    interface A
+      abstract static foo: number = 10
+    endinterface
+  END
+  v9.CheckSourceFailure(lines, 'E1404: Abstract cannot be used in an 
interface', 3)
 
   # Abbreviate the "abstract" keyword
   lines =<< trim END
diff --git a/src/version.c b/src/version.c
index 7511e5c18..e136a671e 100644
--- a/src/version.c
+++ b/src/version.c
@@ -704,6 +704,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2085,
 /**/
     2084,
 /**/
diff --git a/src/vim9class.c b/src/vim9class.c
index ede310b45..08c371389 100644
--- a/src/vim9class.c
+++ b/src/vim9class.c
@@ -1557,26 +1557,27 @@ early_ret:
                break;
            }
 
+           p = skipwhite(pa + 8);
+           if (STRNCMP(p, "def", 3) != 0 && STRNCMP(p, "static", 6) != 0)
+           {
+               emsg(_(e_abstract_must_be_followed_by_def_or_static));
+               break;
+           }
+
            if (!is_class)
-               // ignore "abstract" in an interface (as all the methods in an
-               // interface are abstract.
-               p = skipwhite(pa + 8);
-           else
            {
-               if (!is_abstract)
-               {
-                   semsg(_(e_abstract_method_in_concrete_class), pa);
-                   break;
-               }
+               // "abstract" not supported in an interface
+               emsg(_(e_abstract_cannot_be_used_in_interface));
+               break;
+           }
 
-               abstract_method = TRUE;
-               p = skipwhite(pa + 8);
-               if (STRNCMP(p, "def", 3) != 0)
-               {
-                   emsg(_(e_abstract_must_be_followed_by_def));
-                   break;
-               }
+           if (!is_abstract)
+           {
+               semsg(_(e_abstract_method_in_concrete_class), pa);
+               break;
            }
+
+           abstract_method = TRUE;
        }
 
        int has_static = FALSE;

-- 
-- 
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/E1qydrK-0002av-0s%40256bit.org.

Raspunde prin e-mail lui