changeset 31833:3516e35f409f v9.0.1249

patch 9.0.1249: cannot export an abstract class Commit: https://github.com/vim/vim/commit/657aea7fc47fb919ce76fad64ba0ec55a1af80f1 Author: Bram Moolenaar <Bram@vim.org> Date: Fri Jan 27 13:16:19 2023 +0000 patch 9.0.1249: cannot export an abstract class Problem: Cannot export an abstract class. (Ernie Rael) Solution: Add the EX_EXPORT flag to :abstract. (closes https://github.com/vim/vim/issues/11884)
author Bram Moolenaar <Bram@vim.org>
date Fri, 27 Jan 2023 14:30:04 +0100
parents b8c29a701f66
children 8d782c45028a
files src/errors.h src/ex_cmds.h src/testdir/test_vim9_class.vim src/version.c src/vim9class.c
diffstat 5 files changed, 39 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/errors.h
+++ b/src/errors.h
@@ -3442,4 +3442,6 @@ EXTERN char e_using_super_not_in_child_c
 	INIT(= N_("E1358: Using \"super\" not in a child class"));
 EXTERN char e_cannot_define_new_function_in_abstract_class[]
 	INIT(= N_("E1359: Cannot define a \"new\" function in an abstract class"));
-#endif
+EXTERN char e_invalid_command_str_expected_str[]
+	INIT(= N_("E476: Invalid command: %s, expected %s"));
+#endif
--- a/src/ex_cmds.h
+++ b/src/ex_cmds.h
@@ -128,7 +128,7 @@ EXCMD(CMD_aboveleft,	"aboveleft",	ex_wro
 	EX_NEEDARG|EX_EXTRA|EX_NOTRLCOM,
 	ADDR_NONE),
 EXCMD(CMD_abstract,	"abstract",	ex_class,
-	EX_EXTRA|EX_TRLBAR|EX_CMDWIN|EX_LOCK_OK,
+	EX_EXTRA|EX_TRLBAR|EX_CMDWIN|EX_LOCK_OK|EX_EXPORT,
 	ADDR_NONE),
 EXCMD(CMD_all,		"all",		ex_all,
 	EX_BANG|EX_RANGE|EX_COUNT|EX_TRLBAR,
--- a/src/testdir/test_vim9_class.vim
+++ b/src/testdir/test_vim9_class.vim
@@ -164,6 +164,24 @@ def Test_class_basic()
   v9.CheckScriptSuccess(lines)
 enddef
 
+def Test_class_interface_wrong_end()
+  var lines =<< trim END
+      vim9script
+      abstract class SomeName
+        this.member = 'text'
+      endinterface
+  END
+  v9.CheckScriptFailure(lines, 'E476: Invalid command: endinterface, expected endclass')
+
+  lines =<< trim END
+      vim9script
+      export interface AnotherName
+        this.member: string
+      endclass
+  END
+  v9.CheckScriptFailure(lines, 'E476: Invalid command: endclass, expected endinterface')
+enddef
+
 def Test_class_member_initializer()
   var lines =<< trim END
       vim9script
@@ -845,6 +863,20 @@ def Test_interface_basics()
       enddef
   END
   v9.CheckScriptSuccess(lines)
+
+  var imported =<< trim END
+      vim9script
+      export abstract class EnterExit
+          def Enter(): void
+          enddef
+          def Exit(): void
+          enddef
+      endclass
+  END
+  writefile(imported, 'XdefIntf2.vim', 'D')
+
+  lines[1] = " import './XdefIntf2.vim' as defIntf"
+  v9.CheckScriptSuccess(lines)
 enddef
 
 def Test_class_implements_interface()
--- a/src/version.c
+++ b/src/version.c
@@ -696,6 +696,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    1249,
+/**/
     1248,
 /**/
     1247,
--- a/src/vim9class.c
+++ b/src/vim9class.c
@@ -423,7 +423,7 @@ early_ret:
 	char *wrong_name = is_class ? "endinterface" : "endclass";
 	if (checkforcmd(&p, wrong_name, is_class ? 5 : 4))
 	{
-	    semsg(_(e_invalid_command_str), line);
+	    semsg(_(e_invalid_command_str_expected_str), line, end_name);
 	    break;
 	}