mirror of
https://github.com/vim/vim.git
synced 2025-07-26 11:04:33 -04:00
patch 9.0.0230: no error for comma missing in list in :def function
Problem: No error for comma missing in list in :def function. Solution: Check for missing comma. (closes #10943)
This commit is contained in:
parent
62e0e2e54b
commit
2984ed31d9
@ -2128,7 +2128,7 @@ def Test_var_declaration_fails()
|
|||||||
'floats', 'floot',
|
'floats', 'floot',
|
||||||
'funcs', 'funk',
|
'funcs', 'funk',
|
||||||
'jobs', 'jop',
|
'jobs', 'jop',
|
||||||
'lists', 'last'
|
'lists', 'last',
|
||||||
'numbers', 'numbar',
|
'numbers', 'numbar',
|
||||||
'strings', 'strung',
|
'strings', 'strung',
|
||||||
'voids', 'viod']
|
'voids', 'viod']
|
||||||
@ -2439,11 +2439,11 @@ def Test_unlet()
|
|||||||
], 'E1105:', 2)
|
], 'E1105:', 2)
|
||||||
|
|
||||||
v9.CheckDefExecFailure([
|
v9.CheckDefExecFailure([
|
||||||
'g:dd = {"a": 1, 2: 2}'
|
'g:dd = {"a": 1, 2: 2}',
|
||||||
'unlet g:dd[0z11]',
|
'unlet g:dd[0z11]',
|
||||||
], 'E1029:', 2)
|
], 'E1029:', 2)
|
||||||
v9.CheckDefExecFailure([
|
v9.CheckDefExecFailure([
|
||||||
'g:str = "a string"'
|
'g:str = "a string"',
|
||||||
'unlet g:str[0]',
|
'unlet g:str[0]',
|
||||||
], 'E1148: Cannot index a string', 2)
|
], 'E1148: Cannot index a string', 2)
|
||||||
|
|
||||||
|
@ -2106,7 +2106,7 @@ def Test_disassemble_compare()
|
|||||||
' var aDict = {x: 2}',
|
' var aDict = {x: 2}',
|
||||||
floatDecl,
|
floatDecl,
|
||||||
' if ' .. case[0],
|
' if ' .. case[0],
|
||||||
' echo 42'
|
' echo 42',
|
||||||
' endif',
|
' endif',
|
||||||
'enddef'], 'Xdisassemble')
|
'enddef'], 'Xdisassemble')
|
||||||
source Xdisassemble
|
source Xdisassemble
|
||||||
@ -2163,7 +2163,7 @@ def Test_disassemble_compare_const()
|
|||||||
for case in cases
|
for case in cases
|
||||||
writefile(['def TestCase' .. nr .. '()',
|
writefile(['def TestCase' .. nr .. '()',
|
||||||
' if ' .. case[0],
|
' if ' .. case[0],
|
||||||
' echo 42'
|
' echo 42',
|
||||||
' endif',
|
' endif',
|
||||||
'enddef'], 'Xdisassemble')
|
'enddef'], 'Xdisassemble')
|
||||||
source Xdisassemble
|
source Xdisassemble
|
||||||
|
@ -1876,9 +1876,9 @@ def Test_expr7()
|
|||||||
|
|
||||||
if has('float')
|
if has('float')
|
||||||
v9.CheckDefExecAndScriptFailure([
|
v9.CheckDefExecAndScriptFailure([
|
||||||
'g:one = 1.0'
|
'g:one = 1.0',
|
||||||
'g:two = 2.0'
|
'g:two = 2.0',
|
||||||
'echo g:one % g:two'
|
'echo g:one % g:two',
|
||||||
], 'E804', 3)
|
], 'E804', 3)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@ -2490,6 +2490,7 @@ def Test_expr9_lambda()
|
|||||||
|
|
||||||
v9.CheckDefAndScriptSuccess(['var Fx = (a) => [0,', ' 1]'])
|
v9.CheckDefAndScriptSuccess(['var Fx = (a) => [0,', ' 1]'])
|
||||||
v9.CheckDefAndScriptFailure(['var Fx = (a) => [0', ' 1]'], 'E696:', 2)
|
v9.CheckDefAndScriptFailure(['var Fx = (a) => [0', ' 1]'], 'E696:', 2)
|
||||||
|
v9.CheckDefAndScriptFailure(['var l = [1 2]'], 'E696:', 1)
|
||||||
|
|
||||||
# no error for existing script variable when checking for lambda
|
# no error for existing script variable when checking for lambda
|
||||||
lines =<< trim END
|
lines =<< trim END
|
||||||
|
@ -440,22 +440,22 @@ def Test_missing_return()
|
|||||||
' echo "no return"',
|
' echo "no return"',
|
||||||
' else',
|
' else',
|
||||||
' return 0',
|
' return 0',
|
||||||
' endif'
|
' endif',
|
||||||
'enddef'], 'E1027:')
|
'enddef'], 'E1027:')
|
||||||
v9.CheckDefFailure(['def Missing(): number',
|
v9.CheckDefFailure(['def Missing(): number',
|
||||||
' if g:cond',
|
' if g:cond',
|
||||||
' return 1',
|
' return 1',
|
||||||
' else',
|
' else',
|
||||||
' echo "no return"',
|
' echo "no return"',
|
||||||
' endif'
|
' endif',
|
||||||
'enddef'], 'E1027:')
|
'enddef'], 'E1027:')
|
||||||
v9.CheckDefFailure(['def Missing(): number',
|
v9.CheckDefFailure(['def Missing(): number',
|
||||||
' if g:cond',
|
' if g:cond',
|
||||||
' return 1',
|
' return 1',
|
||||||
' else',
|
' else',
|
||||||
' return 2',
|
' return 2',
|
||||||
' endif'
|
' endif',
|
||||||
' return 3'
|
' return 3',
|
||||||
'enddef'], 'E1095:')
|
'enddef'], 'E1095:')
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
@ -1496,7 +1496,7 @@ enddef
|
|||||||
|
|
||||||
def Test_lambda_uses_assigned_var()
|
def Test_lambda_uses_assigned_var()
|
||||||
v9.CheckDefSuccess([
|
v9.CheckDefSuccess([
|
||||||
'var x: any = "aaa"'
|
'var x: any = "aaa"',
|
||||||
'x = filter(["bbb"], (_, v) => v =~ x)'])
|
'x = filter(["bbb"], (_, v) => v =~ x)'])
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
|
@ -3274,7 +3274,7 @@ def Test_vim9_comment_not_compiled()
|
|||||||
|
|
||||||
v9.CheckScriptSuccess([
|
v9.CheckScriptSuccess([
|
||||||
'vim9script',
|
'vim9script',
|
||||||
'new'
|
'new',
|
||||||
'setline(1, ["# define pat", "last"])',
|
'setline(1, ["# define pat", "last"])',
|
||||||
':$',
|
':$',
|
||||||
'dsearch /pat/ #comment',
|
'dsearch /pat/ #comment',
|
||||||
@ -3283,7 +3283,7 @@ def Test_vim9_comment_not_compiled()
|
|||||||
|
|
||||||
v9.CheckScriptFailure([
|
v9.CheckScriptFailure([
|
||||||
'vim9script',
|
'vim9script',
|
||||||
'new'
|
'new',
|
||||||
'setline(1, ["# define pat", "last"])',
|
'setline(1, ["# define pat", "last"])',
|
||||||
':$',
|
':$',
|
||||||
'dsearch /pat/#comment',
|
'dsearch /pat/#comment',
|
||||||
|
@ -731,6 +731,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 */
|
||||||
|
/**/
|
||||||
|
230,
|
||||||
/**/
|
/**/
|
||||||
229,
|
229,
|
||||||
/**/
|
/**/
|
||||||
|
@ -975,6 +975,7 @@ compile_list(char_u **arg, cctx_T *cctx, ppconst_T *ppconst)
|
|||||||
int count = 0;
|
int count = 0;
|
||||||
int is_const;
|
int is_const;
|
||||||
int is_all_const = TRUE; // reset when non-const encountered
|
int is_all_const = TRUE; // reset when non-const encountered
|
||||||
|
int must_end = FALSE;
|
||||||
|
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
@ -993,6 +994,11 @@ compile_list(char_u **arg, cctx_T *cctx, ppconst_T *ppconst)
|
|||||||
++p;
|
++p;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (must_end)
|
||||||
|
{
|
||||||
|
semsg(_(e_missing_comma_in_list_str), p);
|
||||||
|
return FAIL;
|
||||||
|
}
|
||||||
if (compile_expr0_ext(&p, cctx, &is_const) == FAIL)
|
if (compile_expr0_ext(&p, cctx, &is_const) == FAIL)
|
||||||
return FAIL;
|
return FAIL;
|
||||||
if (!is_const)
|
if (!is_const)
|
||||||
@ -1007,6 +1013,8 @@ compile_list(char_u **arg, cctx_T *cctx, ppconst_T *ppconst)
|
|||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
must_end = TRUE;
|
||||||
whitep = p;
|
whitep = p;
|
||||||
p = skipwhite(p);
|
p = skipwhite(p);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user