To: vim_dev@googlegroups.com Subject: Patch 8.2.1674 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.1674 Problem: Vim9: internal error when using variable that was not set. Solution: Give a meaningful error. (closes #6937) Files: src/vim9script.c, src/testdir/test_vim9_script.vim *** ../vim-8.2.1673/src/vim9script.c 2020-09-09 22:27:55.425537078 +0200 --- src/vim9script.c 2020-09-13 18:52:53.967565840 +0200 *************** *** 548,554 **** // Create the variable with 0/NULL value. CLEAR_FIELD(init_tv); ! init_tv.v_type = type->tt_type; set_var_const(name, type, &init_tv, FALSE, 0); vim_free(name); --- 548,558 ---- // Create the variable with 0/NULL value. CLEAR_FIELD(init_tv); ! if (type->tt_type == VAR_ANY) ! // A variable of type "any" is not possible, just use zero instead ! init_tv.v_type = VAR_NUMBER; ! else ! init_tv.v_type = type->tt_type; set_var_const(name, type, &init_tv, FALSE, 0); vim_free(name); *** ../vim-8.2.1673/src/testdir/test_vim9_script.vim 2020-09-09 22:27:55.429537066 +0200 --- src/testdir/test_vim9_script.vim 2020-09-13 18:55:04.207109626 +0200 *************** *** 3308,3313 **** --- 3308,3321 ---- delete('Xdidit') enddef + def Test_unset_any_variable() + let lines =<< trim END + let var: any + assert_equal(0, var) + END + CheckDefAndScriptSuccess(lines) + enddef + " Keep this last, it messes up highlighting. def Test_substitute_cmd() new *** ../vim-8.2.1673/src/version.c 2020-09-12 22:52:53.582315764 +0200 --- src/version.c 2020-09-13 18:55:13.527077095 +0200 *************** *** 752,753 **** --- 752,755 ---- { /* Add new patch number below this line */ + /**/ + 1674, /**/ -- bashian roulette: $ ((RANDOM%6)) || rm -rf ~ /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///