Problem: No error for comma missing in list in :def function.
Solution: Check for missing comma. (closes #10943)
'floats', 'floot',
'funcs', 'funk',
'jobs', 'jop',
- 'lists', 'last'
+ 'lists', 'last',
'numbers', 'numbar',
'strings', 'strung',
'voids', 'viod']
], '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)
' var aDict = {x: 2}',
floatDecl,
' if ' .. case[0],
- ' echo 42'
+ ' echo 42',
' endif',
'enddef'], 'Xdisassemble')
source Xdisassemble
for case in cases
writefile(['def TestCase' .. nr .. '()',
' if ' .. case[0],
- ' echo 42'
+ ' echo 42',
' endif',
'enddef'], 'Xdisassemble')
source Xdisassemble
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
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
' 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
def Test_lambda_uses_assigned_var()
v9.CheckDefSuccess([
- 'var x: any = "aaa"'
+ 'var x: any = "aaa"',
'x = filter(["bbb"], (_, v) => v =~ x)'])
enddef
v9.CheckScriptSuccess([
'vim9script',
- 'new'
+ 'new',
'setline(1, ["# define pat", "last"])',
':$',
'dsearch /pat/ #comment',
v9.CheckScriptFailure([
'vim9script',
- 'new'
+ 'new',
'setline(1, ["# define pat", "last"])',
':$',
'dsearch /pat/#comment',
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 230,
/**/
229,
/**/
int count = 0;
int is_const;
int is_all_const = TRUE; // reset when non-const encountered
+ int must_end = FALSE;
for (;;)
{
++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)
return FAIL;
}
}
+ else
+ must_end = TRUE;
whitep = p;
p = skipwhite(p);
}