patch 8.2.4643: Vim9: variable may be locked unintentionally
Problem: Vim9: variable may be locked unintentionally.
Solution: Clear "v_lock". (closes #10036)
diff --git a/src/testdir/test_vim9_builtin.vim b/src/testdir/test_vim9_builtin.vim
index 24a7f95..01f29d9 100644
--- a/src/testdir/test_vim9_builtin.vim
+++ b/src/testdir/test_vim9_builtin.vim
@@ -371,10 +371,17 @@
assert_fails('bufname([])', 'E1220:')
enddef
+let s:bufnr_res = 0
+
def Test_bufnr()
var buf = bufnr()
bufnr('%')->assert_equal(buf)
+ # check the lock is not taken over through the stack
+ const nr = 10
+ bufnr_res = bufnr()
+ bufnr_res = 12345
+
buf = bufnr('Xdummy', true)
buf->assert_notequal(-1)
exe 'bwipe! ' .. buf
diff --git a/src/version.c b/src/version.c
index 9d3afeb..fe7f299 100644
--- a/src/version.c
+++ b/src/version.c
@@ -751,6 +751,8 @@
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 4643,
+/**/
4642,
/**/
4641,
diff --git a/src/vim9execute.c b/src/vim9execute.c
index a95a488..c5dc30d 100644
--- a/src/vim9execute.c
+++ b/src/vim9execute.c
@@ -937,6 +937,7 @@
tv = STACK_TV_BOT(-1);
tv->v_type = VAR_NUMBER;
tv->vval.v_number = 0;
+ tv->v_lock = 0;
return OK;
}