diff options
author | Bram Moolenaar <Bram@vim.org> | 2020-02-19 12:40:39 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2020-02-19 12:40:39 +0100 |
commit | 38a5f517a70d7b76361152d2898d7f826c5b2491 (patch) | |
tree | ddbd05c9e4e482ff15e5aedafc4c4f7e923d8571 | |
parent | 406cd90f1963ca60813db91c413eef4b1b78ee44 (diff) | |
download | vim-git-38a5f517a70d7b76361152d2898d7f826c5b2491.tar.gz |
patch 8.2.0276: Vim9: not allowing space before ")" in function callv8.2.0276
Problem: Vim9: not allowing space before ")" in function call is too
restrictive. (Ben Jackson)
Solution: Skip space before the ")". Adjust other space checks.
-rw-r--r-- | src/testdir/test_vim9_expr.vim | 20 | ||||
-rw-r--r-- | src/version.c | 2 | ||||
-rw-r--r-- | src/vim9compile.c | 14 |
3 files changed, 35 insertions, 1 deletions
diff --git a/src/testdir/test_vim9_expr.vim b/src/testdir/test_vim9_expr.vim index c0767f517..1f3e41761 100644 --- a/src/testdir/test_vim9_expr.vim +++ b/src/testdir/test_vim9_expr.vim @@ -9,6 +9,14 @@ func CheckDefFailure(line, error) call delete('Xdef') endfunc +" Check that "line" inside ":def" results in an "error" message when executed. +func CheckDefExecFailure(line, error) + call writefile(['def! Func()', a:line, 'enddef'], 'Xdef') + so Xdef + call assert_fails('call Func()', a:error, a:line) + call delete('Xdef') +endfunc + func CheckDefFailureList(lines, error) call writefile(['def! Func()'] + a:lines + ['enddef'], 'Xdef') call assert_fails('so Xdef', a:error, string(a:lines)) @@ -725,9 +733,17 @@ func CallMe(arg) return a:arg endfunc +func CallMe2(one, two) + return a:one .. a:two +endfunc + def Test_expr7_trailing() " user function call assert_equal(123, CallMe(123)) + assert_equal(123, CallMe( 123)) + assert_equal(123, CallMe(123 )) + assert_equal('yesno', CallMe2('yes', 'no')) + assert_equal('yesno', CallMe2( 'yes', 'no' )) assert_equal('nothing', CallMe('nothing')) " partial call @@ -761,4 +777,8 @@ endfunc func Test_expr_fails() call CheckDefFailure("let x = '1'is2", 'E488:') call CheckDefFailure("let x = '1'isnot2", 'E488:') + + call CheckDefExecFailure("CallMe ('yes')", 'E492:') + call CheckDefFailure("CallMe2('yes','no')", 'E1069:') + call CheckDefFailure("CallMe2('yes' , 'no')", 'E1068:') endfunc diff --git a/src/version.c b/src/version.c index 41d021f7e..5095de483 100644 --- a/src/version.c +++ b/src/version.c @@ -739,6 +739,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 276, +/**/ 275, /**/ 274, diff --git a/src/vim9compile.c b/src/vim9compile.c index adfcbcc8f..8614943fd 100644 --- a/src/vim9compile.c +++ b/src/vim9compile.c @@ -1658,9 +1658,21 @@ compile_arguments(char_u **arg, cctx_T *cctx, int *argcount) if (compile_expr1(&p, cctx) == FAIL) return FAIL; ++*argcount; + + if (*p != ',' && *skipwhite(p) == ',') + { + emsg(_("E1068: No white space allowed before ,")); + p = skipwhite(p); + } if (*p == ',') - p = skipwhite(p + 1); + { + ++p; + if (!VIM_ISWHITE(*p)) + emsg(_("E1069: white space required after ,")); + } + p = skipwhite(p); } + p = skipwhite(p); if (*p != ')') { emsg(_(e_missing_close)); |