Skip to content

Commit

Permalink
patch 9.0.1249: cannot export an abstract class
Browse files Browse the repository at this point in the history
Problem:    Cannot export an abstract class. (Ernie Rael)
Solution:   Add the EX_EXPORT flag to :abstract. (closes #11884)
  • Loading branch information
brammool committed Jan 27, 2023
1 parent 53f54e4 commit 657aea7
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/errors.h
Expand Up @@ -3442,4 +3442,6 @@ EXTERN char e_using_super_not_in_child_class[]
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"));
EXTERN char e_invalid_command_str_expected_str[]
INIT(= N_("E476: Invalid command: %s, expected %s"));
#endif
2 changes: 1 addition & 1 deletion src/ex_cmds.h
Expand Up @@ -128,7 +128,7 @@ EXCMD(CMD_aboveleft, "aboveleft", ex_wrongmodifier,
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,
Expand Down
32 changes: 32 additions & 0 deletions src/testdir/test_vim9_class.vim
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down
2 changes: 2 additions & 0 deletions src/version.c
Expand Up @@ -695,6 +695,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
/**/
1249,
/**/
1248,
/**/
Expand Down
2 changes: 1 addition & 1 deletion src/vim9class.c
Expand Up @@ -423,7 +423,7 @@ ex_class(exarg_T *eap)
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;
}

Expand Down

0 comments on commit 657aea7

Please sign in to comment.