mirror of
https://github.com/vim/vim.git
synced 2025-07-26 11:04:33 -04:00
patch 9.0.1355: no error when declaring a class twice
Problem: No error when declaring a class twice. (Ernie Rael) Solution: Pass different flags when declaring the class. (closes #12057)
This commit is contained in:
parent
d6a4ea3aa0
commit
83ae6150bf
@ -164,6 +164,28 @@ def Test_class_basic()
|
||||
v9.CheckScriptSuccess(lines)
|
||||
enddef
|
||||
|
||||
def Test_class_defined_twice()
|
||||
# class defined twice should fail
|
||||
var lines =<< trim END
|
||||
vim9script
|
||||
class There
|
||||
endclass
|
||||
class There
|
||||
endclass
|
||||
END
|
||||
v9.CheckScriptFailure(lines, 'E1041: Redefining script item: "There"')
|
||||
|
||||
# one class, reload same script twice is OK
|
||||
lines =<< trim END
|
||||
vim9script
|
||||
class There
|
||||
endclass
|
||||
END
|
||||
writefile(lines, 'XclassTwice.vim', 'D')
|
||||
source XclassTwice.vim
|
||||
source XclassTwice.vim
|
||||
enddef
|
||||
|
||||
def Test_class_interface_wrong_end()
|
||||
var lines =<< trim END
|
||||
vim9script
|
||||
@ -1012,14 +1034,13 @@ def Test_class_implements_interface()
|
||||
this.member: string
|
||||
endinterface
|
||||
|
||||
class SomeImpl implements Some, Another
|
||||
class AnotherImpl implements Some, Another
|
||||
this.member = 'abc'
|
||||
static count: number
|
||||
def Method(nr: number)
|
||||
echo nr
|
||||
enddef
|
||||
endclass
|
||||
|
||||
END
|
||||
v9.CheckScriptSuccess(lines)
|
||||
|
||||
|
@ -695,6 +695,8 @@ static char *(features[]) =
|
||||
|
||||
static int included_patches[] =
|
||||
{ /* Add new patch number below this line */
|
||||
/**/
|
||||
1355,
|
||||
/**/
|
||||
1354,
|
||||
/**/
|
||||
|
@ -230,7 +230,8 @@ object_index_from_itf_index(class_T *itf, int is_method, int idx, class_T *cl)
|
||||
void
|
||||
ex_class(exarg_T *eap)
|
||||
{
|
||||
int is_class = eap->cmdidx == CMD_class; // FALSE for :interface
|
||||
int is_class = eap->cmdidx == CMD_class; // FALSE for :interface
|
||||
long start_lnum = SOURCING_LNUM;
|
||||
|
||||
char_u *arg = eap->arg;
|
||||
int is_abstract = eap->cmdidx == CMD_abstract;
|
||||
@ -1097,8 +1098,9 @@ early_ret:
|
||||
tv.v_type = VAR_CLASS;
|
||||
tv.vval.v_class = cl;
|
||||
is_export = class_export;
|
||||
SOURCING_LNUM = start_lnum;
|
||||
set_var_const(cl->class_name, current_sctx.sc_sid,
|
||||
NULL, &tv, FALSE, ASSIGN_DECL, 0);
|
||||
NULL, &tv, FALSE, 0, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user