diff options
author | zeertzjq <zeertzjq@outlook.com> | 2024-05-24 18:29:17 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-24 18:29:17 +0800 |
commit | 8db9a0e5a26616a84903ca29cd5a877df9037bd8 (patch) | |
tree | 56fd141e43a2a9fcb3f894ee1e38996fffc0b80a | |
parent | a616272f568a9492580abfd22ab460457ecdbfa3 (diff) | |
download | rneovim-8db9a0e5a26616a84903ca29cd5a877df9037bd8.tar.gz rneovim-8db9a0e5a26616a84903ca29cd5a877df9037bd8.tar.bz2 rneovim-8db9a0e5a26616a84903ca29cd5a877df9037bd8.zip |
vim-patch:8.2.3158: strange error message when using islocked() with a number (#28962)
Problem: Strange error message when using islocked() with a number.
(Yegappan Lakshmanan)
Solution: Check that the name is empty.
https://github.com/vim/vim/commit/1840a7b4e3577e617f724c9d07ccc78195cc010a
Use ll_name_len instead.
Co-authored-by: Bram Moolenaar <Bram@vim.org>
-rw-r--r-- | src/nvim/eval.c | 1 | ||||
-rw-r--r-- | src/nvim/eval/funcs.c | 2 | ||||
-rw-r--r-- | test/old/testdir/test_functions.vim | 5 |
3 files changed, 7 insertions, 1 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 18e5dc7cbd..c1c1f551a8 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -1737,6 +1737,7 @@ char *get_lval(char *const name, typval_T *const rettv, lval_T *const lp, const } tv_clear(&var1); + lp->ll_name_len = (size_t)(p - lp->ll_name); return p; } diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c index 048f744532..e4cb63eb8e 100644 --- a/src/nvim/eval/funcs.c +++ b/src/nvim/eval/funcs.c @@ -4119,7 +4119,7 @@ static void f_islocked(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) FNE_CHECK_START); if (end != NULL && lv.ll_name != NULL) { if (*end != NUL) { - semsg(_(e_trailing_arg), end); + semsg(_(lv.ll_name_len == 0 ? e_invarg2 : e_trailing_arg), end); } else { if (lv.ll_tv == NULL) { dictitem_T *di = find_var(lv.ll_name, lv.ll_name_len, NULL, true); diff --git a/test/old/testdir/test_functions.vim b/test/old/testdir/test_functions.vim index 7c712818f9..18d0d9aa5d 100644 --- a/test/old/testdir/test_functions.vim +++ b/test/old/testdir/test_functions.vim @@ -98,6 +98,11 @@ func Test_err_teapot() call assert_fails('call err_teapot(expr)', "E503: Coffee is currently not available") endfunc +func Test_islocked() + call assert_fails('call islocked(99)', 'E475:') + call assert_fails('call islocked("s: x")', 'E488:') +endfunc + func Test_len() call assert_equal(1, len(0)) call assert_equal(2, len(12)) |