To: vim_dev@googlegroups.com Subject: Patch 8.2.4371 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.4371 Problem: Vim9: can create a script variable from a legacy function. Solution: Disallow creating a script variable from a function. Files: src/evalvars.c, src/errors.h, src/testdir/test_vim9_script.vim *** ../vim-8.2.4370/src/evalvars.c 2022-02-07 13:56:40.592793019 +0000 --- src/evalvars.c 2022-02-13 13:48:50.495193261 +0000 *************** *** 3504,3509 **** --- 3504,3515 ---- semsg(_(e_cannot_use_str_itself_it_is_imported), name); goto failed; } + if (!in_vim9script()) + { + semsg(_(e_cannot_create_vim9_script_variable_in_function_str), + name); + goto failed; + } } if (dest_tv == NULL) *** ../vim-8.2.4370/src/errors.h 2022-02-12 19:52:22.024702251 +0000 --- src/errors.h 2022-02-13 13:49:14.635161369 +0000 *************** *** 3234,3237 **** --- 3234,3239 ---- INIT(= N_("E1267: Function name must start with a capital: %s")); EXTERN char e_cannot_use_s_colon_in_vim9_script_str[] INIT(= N_("E1268: Cannot use s: in Vim9 script: %s")); + EXTERN char e_cannot_create_vim9_script_variable_in_function_str[] + INIT(= N_("E1269: Cannot create a Vim9 script variable in a function: %s")); #endif *** ../vim-8.2.4370/src/testdir/test_vim9_script.vim 2022-02-12 19:52:22.028702244 +0000 --- src/testdir/test_vim9_script.vim 2022-02-13 13:54:21.586563480 +0000 *************** *** 3071,3083 **** delete('Xforward') enddef ! def Test_declare_script_in_func() var lines =<< trim END vim9script func Declare() let s:local = 123 endfunc Declare() assert_equal(123, local) var error: string --- 3071,3091 ---- delete('Xforward') enddef ! def Test_declare_script_var_in_func() var lines =<< trim END vim9script func Declare() let s:local = 123 endfunc Declare() + END + v9.CheckScriptFailure(lines, 'E1269:') + enddef + + def Test_lock_script_var() + var lines =<< trim END + vim9script + var local = 123 assert_equal(123, local) var error: string *** ../vim-8.2.4370/src/version.c 2022-02-13 13:11:27.382107371 +0000 --- src/version.c 2022-02-13 13:46:08.751406838 +0000 *************** *** 752,753 **** --- 752,755 ---- { /* Add new patch number below this line */ + /**/ + 4371, /**/ -- On the other hand, you have different fingers. -- Steven Wright /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///