diff options
author | Bram Moolenaar <Bram@vim.org> | 2021-11-22 21:58:41 +0000 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2021-11-22 21:58:41 +0000 |
commit | 04b568b38f848293e1ae0e680685280151acb386 (patch) | |
tree | 4ecf2787718a1bf00ca71be8190c01a820e6e1db | |
parent | 3b3755fe19e9ded2a1c45f14b2c6fa065bcaf2c6 (diff) | |
download | vim-git-04b568b38f848293e1ae0e680685280151acb386.tar.gz |
patch 8.2.3651: Vim9: no error for :lock or :unlock with unknown variablev8.2.3651
Problem: Vim9: no error for :lock or :unlock with unknown variable.
Solution: Give an error. (closes #9188)
-rw-r--r-- | src/errors.h | 2 | ||||
-rw-r--r-- | src/evalvars.c | 5 | ||||
-rw-r--r-- | src/testdir/test_vim9_cmd.vim | 17 | ||||
-rw-r--r-- | src/version.c | 2 |
4 files changed, 26 insertions, 0 deletions
diff --git a/src/errors.h b/src/errors.h index 753e2fe41..cde98461e 100644 --- a/src/errors.h +++ b/src/errors.h @@ -686,3 +686,5 @@ EXTERN char e_bad_color_string_str[] INIT(= N_("E1244: Bad color string: %s")); EXTERN char e_cannot_expand_sfile_in_vim9_function[] INIT(= N_("E1245: Cannot expand <sfile> in a Vim9 function")); +EXTERN char e_cannot_find_variable_to_unlock_str[] + INIT(= N_("E1246: Cannot find variable to (un)lock: %s")); diff --git a/src/evalvars.c b/src/evalvars.c index b56073453..b1d7b78c8 100644 --- a/src/evalvars.c +++ b/src/evalvars.c @@ -1827,7 +1827,12 @@ do_lock_var( // Normal name or expanded name. di = find_var(lp->ll_name, NULL, TRUE); if (di == NULL) + { + if (in_vim9script()) + semsg(_(e_cannot_find_variable_to_unlock_str), + lp->ll_name); ret = FAIL; + } else if ((di->di_flags & DI_FLAGS_FIX) && di->di_tv.v_type != VAR_DICT && di->di_tv.v_type != VAR_LIST) diff --git a/src/testdir/test_vim9_cmd.vim b/src/testdir/test_vim9_cmd.vim index 31f20cb26..16f5d55d0 100644 --- a/src/testdir/test_vim9_cmd.vim +++ b/src/testdir/test_vim9_cmd.vim @@ -1370,6 +1370,23 @@ def Test_lockvar() unlockvar theList END CheckDefFailure(lines, 'E1178', 2) + + lines =<< trim END + vim9script + var name = 'john' + lockvar nameX + END + CheckScriptFailure(lines, 'E1246', 3) + + lines =<< trim END + vim9script + var name = 'john' + def LockIt() + lockvar nameX + enddef + LockIt() + END + CheckScriptFailure(lines, 'E1246', 1) enddef def Test_substitute_expr() diff --git a/src/version.c b/src/version.c index 121ce6eae..f2bcb190f 100644 --- a/src/version.c +++ b/src/version.c @@ -758,6 +758,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 3651, +/**/ 3650, /**/ 3649, |