Skip to content

Commit 657aea7

Browse files
committed
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 #11884)
1 parent 53f54e4 commit 657aea7

5 files changed

Lines changed: 38 additions & 2 deletions

File tree

src/errors.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3442,4 +3442,6 @@ EXTERN char e_using_super_not_in_child_class[]
34423442
INIT(= N_("E1358: Using \"super\" not in a child class"));
34433443
EXTERN char e_cannot_define_new_function_in_abstract_class[]
34443444
INIT(= N_("E1359: Cannot define a \"new\" function in an abstract class"));
3445+
EXTERN char e_invalid_command_str_expected_str[]
3446+
INIT(= N_("E476: Invalid command: %s, expected %s"));
34453447
#endif

src/ex_cmds.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ EXCMD(CMD_aboveleft, "aboveleft", ex_wrongmodifier,
128128
EX_NEEDARG|EX_EXTRA|EX_NOTRLCOM,
129129
ADDR_NONE),
130130
EXCMD(CMD_abstract, "abstract", ex_class,
131-
EX_EXTRA|EX_TRLBAR|EX_CMDWIN|EX_LOCK_OK,
131+
EX_EXTRA|EX_TRLBAR|EX_CMDWIN|EX_LOCK_OK|EX_EXPORT,
132132
ADDR_NONE),
133133
EXCMD(CMD_all, "all", ex_all,
134134
EX_BANG|EX_RANGE|EX_COUNT|EX_TRLBAR,

src/testdir/test_vim9_class.vim

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,24 @@ def Test_class_basic()
164164
v9.CheckScriptSuccess(lines)
165165
enddef
166166

167+
def Test_class_interface_wrong_end()
168+
var lines =<< trim END
169+
vim9script
170+
abstract class SomeName
171+
this.member = 'text'
172+
endinterface
173+
END
174+
v9.CheckScriptFailure(lines, 'E476: Invalid command: endinterface, expected endclass')
175+
176+
lines =<< trim END
177+
vim9script
178+
export interface AnotherName
179+
this.member: string
180+
endclass
181+
END
182+
v9.CheckScriptFailure(lines, 'E476: Invalid command: endclass, expected endinterface')
183+
enddef
184+
167185
def Test_class_member_initializer()
168186
var lines =<< trim END
169187
vim9script
@@ -845,6 +863,20 @@ def Test_interface_basics()
845863
enddef
846864
END
847865
v9.CheckScriptSuccess(lines)
866+
867+
var imported =<< trim END
868+
vim9script
869+
export abstract class EnterExit
870+
def Enter(): void
871+
enddef
872+
def Exit(): void
873+
enddef
874+
endclass
875+
END
876+
writefile(imported, 'XdefIntf2.vim', 'D')
877+
878+
lines[1] = " import './XdefIntf2.vim' as defIntf"
879+
v9.CheckScriptSuccess(lines)
848880
enddef
849881

850882
def Test_class_implements_interface()

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -695,6 +695,8 @@ static char *(features[]) =
695695

696696
static int included_patches[] =
697697
{ /* Add new patch number below this line */
698+
/**/
699+
1249,
698700
/**/
699701
1248,
700702
/**/

src/vim9class.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ ex_class(exarg_T *eap)
423423
char *wrong_name = is_class ? "endinterface" : "endclass";
424424
if (checkforcmd(&p, wrong_name, is_class ? 5 : 4))
425425
{
426-
semsg(_(e_invalid_command_str), line);
426+
semsg(_(e_invalid_command_str_expected_str), line, end_name);
427427
break;
428428
}
429429

0 commit comments

Comments
 (0)