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',
|
||||
'funcs', 'funk',
|
||||
'jobs', 'jop',
|
||||
'lists', 'last'
|
||||
'lists', 'last',
|
||||
'numbers', 'numbar',
|
||||
'strings', 'strung',
|
||||
'voids', 'viod']
|
||||
@ -2439,11 +2439,11 @@ def Test_unlet()
|
||||
], 'E1105:', 2)
|
||||
|
||||
v9.CheckDefExecFailure([
|
||||
'g:dd = {"a": 1, 2: 2}'
|
||||
'g:dd = {"a": 1, 2: 2}',
|
||||
'unlet g:dd[0z11]',
|
||||
], 'E1029:', 2)
|
||||
v9.CheckDefExecFailure([
|
||||
'g:str = "a string"'
|
||||
'g:str = "a string"',
|
||||
'unlet g:str[0]',
|
||||
], 'E1148: Cannot index a string', 2)
|
||||
|
||||
|
@ -2106,7 +2106,7 @@ def Test_disassemble_compare()
|
||||
' var aDict = {x: 2}',
|
||||
floatDecl,
|
||||
' if ' .. case[0],
|
||||
' echo 42'
|
||||
' echo 42',
|
||||
' endif',
|
||||
'enddef'], 'Xdisassemble')
|
||||
source Xdisassemble
|
||||
@ -2163,7 +2163,7 @@ def Test_disassemble_compare_const()
|
||||
for case in cases
|
||||
writefile(['def TestCase' .. nr .. '()',
|
||||
' if ' .. case[0],
|
||||
' echo 42'
|
||||
' echo 42',
|
||||
' endif',
|
||||
'enddef'], 'Xdisassemble')
|
||||
source Xdisassemble
|
||||
|
@ -1876,9 +1876,9 @@ def Test_expr7()
|
||||
|
||||
if has('float')
|
||||
v9.CheckDefExecAndScriptFailure([
|
||||
'g:one = 1.0'
|
||||
'g:two = 2.0'
|
||||
'echo g:one % g:two'
|
||||
'g:one = 1.0',
|
||||
'g:two = 2.0',
|
||||
'echo g:one % g:two',
|
||||
], 'E804', 3)
|
||||
endif
|
||||
|
||||
@ -2490,6 +2490,7 @@ def Test_expr9_lambda()
|
||||
|
||||
v9.CheckDefAndScriptSuccess(['var Fx = (a) => [0,', ' 1]'])
|
||||
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
|
||||
lines =<< trim END
|
||||
|
@ -440,22 +440,22 @@ def Test_missing_return()
|
||||
' echo "no return"',
|
||||
' else',
|
||||
' return 0',
|
||||
' endif'
|
||||
' endif',
|
||||
'enddef'], 'E1027:')
|
||||
v9.CheckDefFailure(['def Missing(): number',
|
||||
' if g:cond',
|
||||
' return 1',
|
||||
' else',
|
||||
' echo "no return"',
|
||||
' endif'
|
||||
' endif',
|
||||
'enddef'], 'E1027:')
|
||||
v9.CheckDefFailure(['def Missing(): number',
|
||||
' if g:cond',
|
||||
' return 1',
|
||||
' else',
|
||||
' return 2',
|
||||
' endif'
|
||||
' return 3'
|
||||
' endif',
|
||||
' return 3',
|
||||
'enddef'], 'E1095:')
|
||||
enddef
|
||||
|
||||
@ -1496,7 +1496,7 @@ enddef
|
||||
|
||||
def Test_lambda_uses_assigned_var()
|
||||
v9.CheckDefSuccess([
|
||||
'var x: any = "aaa"'
|
||||
'var x: any = "aaa"',
|
||||
'x = filter(["bbb"], (_, v) => v =~ x)'])
|
||||
enddef
|
||||
|
||||
|
@ -3274,7 +3274,7 @@ def Test_vim9_comment_not_compiled()
|
||||
|
||||
v9.CheckScriptSuccess([
|
||||
'vim9script',
|
||||
'new'
|
||||
'new',
|
||||
'setline(1, ["# define pat", "last"])',
|
||||
':$',
|
||||
'dsearch /pat/ #comment',
|
||||
@ -3283,7 +3283,7 @@ def Test_vim9_comment_not_compiled()
|
||||
|
||||
v9.CheckScriptFailure([
|
||||
'vim9script',
|
||||
'new'
|
||||
'new',
|
||||
'setline(1, ["# define pat", "last"])',
|
||||
':$',
|
||||
'dsearch /pat/#comment',
|
||||
|
@ -731,6 +731,8 @@ static char *(features[]) =
|
||||
|
||||
static int included_patches[] =
|
||||
{ /* Add new patch number below this line */
|
||||
/**/
|
||||
230,
|
||||
/**/
|
||||
229,
|
||||
/**/
|
||||
|
@ -975,6 +975,7 @@ compile_list(char_u **arg, cctx_T *cctx, ppconst_T *ppconst)
|
||||
int count = 0;
|
||||
int is_const;
|
||||
int is_all_const = TRUE; // reset when non-const encountered
|
||||
int must_end = FALSE;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
@ -993,6 +994,11 @@ compile_list(char_u **arg, cctx_T *cctx, ppconst_T *ppconst)
|
||||
++p;
|
||||
break;
|
||||
}
|
||||
if (must_end)
|
||||
{
|
||||
semsg(_(e_missing_comma_in_list_str), p);
|
||||
return FAIL;
|
||||
}
|
||||
if (compile_expr0_ext(&p, cctx, &is_const) == FAIL)
|
||||
return FAIL;
|
||||
if (!is_const)
|
||||
@ -1007,6 +1013,8 @@ compile_list(char_u **arg, cctx_T *cctx, ppconst_T *ppconst)
|
||||
return FAIL;
|
||||
}
|
||||
}
|
||||
else
|
||||
must_end = TRUE;
|
||||
whitep = p;
|
||||
p = skipwhite(p);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user