mirror of
https://github.com/vim/vim.git
synced 2025-09-26 04:04:07 -04:00
patch 8.2.0465: Vim9: dead code and wrong return type
Problem: Vim9: dead code and wrong return type. Solution: Remove dead code. Fix return type. Add more tests.
This commit is contained in:
@@ -112,6 +112,16 @@ func Test_assignment_failure()
|
|||||||
|
|
||||||
call CheckDefFailure(['let var: dict <number>'], 'E1007:')
|
call CheckDefFailure(['let var: dict <number>'], 'E1007:')
|
||||||
call CheckDefFailure(['let var: dict<number'], 'E1009:')
|
call CheckDefFailure(['let var: dict<number'], 'E1009:')
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
func Test_wrong_type()
|
||||||
|
call CheckDefFailure(['let var: list<nothing>'], 'E1010:')
|
||||||
|
call CheckDefFailure(['let var: list<list<nothing>>'], 'E1010:')
|
||||||
|
call CheckDefFailure(['let var: dict<nothing>'], 'E1010:')
|
||||||
|
call CheckDefFailure(['let var: dict<dict<nothing>>'], 'E1010:')
|
||||||
|
|
||||||
|
call CheckDefFailure(['let var: dict<number'], 'E1009:')
|
||||||
|
call CheckDefFailure(['let var: dict<list<number>'], 'E1009:')
|
||||||
|
|
||||||
call CheckDefFailure(['let var: ally'], 'E1010:')
|
call CheckDefFailure(['let var: ally'], 'E1010:')
|
||||||
call CheckDefFailure(['let var: bram'], 'E1010:')
|
call CheckDefFailure(['let var: bram'], 'E1010:')
|
||||||
@@ -436,6 +446,37 @@ def Test_vim9_import_export()
|
|||||||
source Ximport.vim
|
source Ximport.vim
|
||||||
assert_equal(9883, g:imported)
|
assert_equal(9883, g:imported)
|
||||||
|
|
||||||
|
let import_star_as_lines_no_dot =<< trim END
|
||||||
|
vim9script
|
||||||
|
import * as Export from './Xexport.vim'
|
||||||
|
def Func()
|
||||||
|
let dummy = 1
|
||||||
|
let imported = Export + dummy
|
||||||
|
enddef
|
||||||
|
END
|
||||||
|
writefile(import_star_as_lines_no_dot, 'Ximport.vim')
|
||||||
|
assert_fails('source Ximport.vim', 'E1060:')
|
||||||
|
|
||||||
|
let import_star_as_lines_dot_space =<< trim END
|
||||||
|
vim9script
|
||||||
|
import * as Export from './Xexport.vim'
|
||||||
|
def Func()
|
||||||
|
let imported = Export . exported
|
||||||
|
enddef
|
||||||
|
END
|
||||||
|
writefile(import_star_as_lines_dot_space, 'Ximport.vim')
|
||||||
|
assert_fails('source Ximport.vim', 'E1074:')
|
||||||
|
|
||||||
|
let import_star_as_lines_missing_name =<< trim END
|
||||||
|
vim9script
|
||||||
|
import * as Export from './Xexport.vim'
|
||||||
|
def Func()
|
||||||
|
let imported = Export.
|
||||||
|
enddef
|
||||||
|
END
|
||||||
|
writefile(import_star_as_lines_missing_name, 'Ximport.vim')
|
||||||
|
assert_fails('source Ximport.vim', 'E1048:')
|
||||||
|
|
||||||
let import_star_lines =<< trim END
|
let import_star_lines =<< trim END
|
||||||
vim9script
|
vim9script
|
||||||
import * from './Xexport.vim'
|
import * from './Xexport.vim'
|
||||||
|
@@ -738,6 +738,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
465,
|
||||||
/**/
|
/**/
|
||||||
464,
|
464,
|
||||||
/**/
|
/**/
|
||||||
|
@@ -242,7 +242,7 @@ get_list_type(type_T *member_type, garray_T *type_list)
|
|||||||
|
|
||||||
// Not a common type, create a new entry.
|
// Not a common type, create a new entry.
|
||||||
if (ga_grow(type_list, 1) == FAIL)
|
if (ga_grow(type_list, 1) == FAIL)
|
||||||
return FAIL;
|
return &t_any;
|
||||||
type = ((type_T *)type_list->ga_data) + type_list->ga_len;
|
type = ((type_T *)type_list->ga_data) + type_list->ga_len;
|
||||||
++type_list->ga_len;
|
++type_list->ga_len;
|
||||||
type->tt_type = VAR_LIST;
|
type->tt_type = VAR_LIST;
|
||||||
@@ -269,7 +269,7 @@ get_dict_type(type_T *member_type, garray_T *type_list)
|
|||||||
|
|
||||||
// Not a common type, create a new entry.
|
// Not a common type, create a new entry.
|
||||||
if (ga_grow(type_list, 1) == FAIL)
|
if (ga_grow(type_list, 1) == FAIL)
|
||||||
return FAIL;
|
return &t_any;
|
||||||
type = ((type_T *)type_list->ga_data) + type_list->ga_len;
|
type = ((type_T *)type_list->ga_data) + type_list->ga_len;
|
||||||
++type_list->ga_len;
|
++type_list->ga_len;
|
||||||
type->tt_type = VAR_DICT;
|
type->tt_type = VAR_DICT;
|
||||||
@@ -1368,6 +1368,7 @@ skip_type(char_u *start)
|
|||||||
parse_type_member(char_u **arg, type_T *type, garray_T *type_list)
|
parse_type_member(char_u **arg, type_T *type, garray_T *type_list)
|
||||||
{
|
{
|
||||||
type_T *member_type;
|
type_T *member_type;
|
||||||
|
int prev_called_emsg = called_emsg;
|
||||||
|
|
||||||
if (**arg != '<')
|
if (**arg != '<')
|
||||||
{
|
{
|
||||||
@@ -1380,11 +1381,9 @@ parse_type_member(char_u **arg, type_T *type, garray_T *type_list)
|
|||||||
*arg = skipwhite(*arg + 1);
|
*arg = skipwhite(*arg + 1);
|
||||||
|
|
||||||
member_type = parse_type(arg, type_list);
|
member_type = parse_type(arg, type_list);
|
||||||
if (member_type == NULL)
|
|
||||||
return type;
|
|
||||||
|
|
||||||
*arg = skipwhite(*arg);
|
*arg = skipwhite(*arg);
|
||||||
if (**arg != '>')
|
if (**arg != '>' && called_emsg == prev_called_emsg)
|
||||||
{
|
{
|
||||||
emsg(_("E1009: Missing > after type"));
|
emsg(_("E1009: Missing > after type"));
|
||||||
return type;
|
return type;
|
||||||
@@ -1766,6 +1765,11 @@ compile_load_scriptvar(
|
|||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
++p;
|
++p;
|
||||||
|
if (VIM_ISWHITE(*p))
|
||||||
|
{
|
||||||
|
emsg(_("E1074: no white space allowed after dot"));
|
||||||
|
return FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
idx = find_exported(import->imp_sid, &p, &name_len, &ufunc, &type);
|
idx = find_exported(import->imp_sid, &p, &name_len, &ufunc, &type);
|
||||||
// TODO: what if it is a function?
|
// TODO: what if it is a function?
|
||||||
@@ -1806,6 +1810,7 @@ compile_load(char_u **arg, char_u *end_arg, cctx_T *cctx, int error)
|
|||||||
char_u *name;
|
char_u *name;
|
||||||
char_u *end = end_arg;
|
char_u *end = end_arg;
|
||||||
int res = FAIL;
|
int res = FAIL;
|
||||||
|
int prev_called_emsg = called_emsg;
|
||||||
|
|
||||||
if (*(*arg + 1) == ':')
|
if (*(*arg + 1) == ':')
|
||||||
{
|
{
|
||||||
@@ -1892,7 +1897,7 @@ compile_load(char_u **arg, char_u *end_arg, cctx_T *cctx, int error)
|
|||||||
*arg = end;
|
*arg = end;
|
||||||
|
|
||||||
theend:
|
theend:
|
||||||
if (res == FAIL && error)
|
if (res == FAIL && error && called_emsg == prev_called_emsg)
|
||||||
semsg(_(e_var_notfound), name);
|
semsg(_(e_var_notfound), name);
|
||||||
vim_free(name);
|
vim_free(name);
|
||||||
return res;
|
return res;
|
||||||
|
Reference in New Issue
Block a user