changeset 28233:e31f1a949d4e v8.2.4643

patch 8.2.4643: Vim9: variable may be locked unintentionally Commit: https://github.com/vim/vim/commit/24565cf27bc28cbd73f10e5ddf1e4ef53038a426 Author: Bram Moolenaar <Bram@vim.org> Date: Mon Mar 28 18:16:52 2022 +0100 patch 8.2.4643: Vim9: variable may be locked unintentionally Problem: Vim9: variable may be locked unintentionally. Solution: Clear "v_lock". (closes https://github.com/vim/vim/issues/10036)
author Bram Moolenaar <Bram@vim.org>
date Mon, 28 Mar 2022 19:30:03 +0200
parents d041bcc0d3d6
children 0a423ed1d2c4
files src/testdir/test_vim9_builtin.vim src/version.c src/vim9execute.c
diffstat 3 files changed, 10 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/testdir/test_vim9_builtin.vim
+++ b/src/testdir/test_vim9_builtin.vim
@@ -371,10 +371,17 @@ def Test_bufname()
   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
--- a/src/version.c
+++ b/src/version.c
@@ -751,6 +751,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    4643,
+/**/
     4642,
 /**/
     4641,
--- a/src/vim9execute.c
+++ b/src/vim9execute.c
@@ -937,6 +937,7 @@ call_prepare(int argcount, typval_T *arg
     tv = STACK_TV_BOT(-1);
     tv->v_type = VAR_NUMBER;
     tv->vval.v_number = 0;
+    tv->v_lock = 0;
 
     return OK;
 }