To: vim_dev@googlegroups.com Subject: Patch 8.2.1257 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.1257 Problem: Vim9: list unpack doesn't work at the script level. Solution: Detect unpack assignment better. (closes #6494) Files: src/ex_docmd.c, src/testdir/test_vim9_script.vim *** ../vim-8.2.1256/src/ex_docmd.c 2020-07-17 20:47:47.640033591 +0200 --- src/ex_docmd.c 2020-07-20 22:27:57.111690166 +0200 *************** *** 3282,3291 **** // after the "]" by to_name_const_end(): check if a "=" follows. // If "[...]" has a line break "p" still points at the "[" and it can't // be an assignment. ! if (*eap->cmd == '[' && (p == eap->cmd || *skipwhite(p) != '=')) { ! eap->cmdidx = CMD_eval; ! return eap->cmd; } // Recognize an assignment if we recognize the variable name: --- 3282,3300 ---- // after the "]" by to_name_const_end(): check if a "=" follows. // If "[...]" has a line break "p" still points at the "[" and it can't // be an assignment. ! if (*eap->cmd == '[') { ! p = to_name_const_end(eap->cmd); ! if (p == eap->cmd || *skipwhite(p) != '=') ! { ! eap->cmdidx = CMD_eval; ! return eap->cmd; ! } ! if (p > eap->cmd && *skipwhite(p) == '=') ! { ! eap->cmdidx = CMD_let; ! return eap->cmd; ! } } // Recognize an assignment if we recognize the variable name: *** ../vim-8.2.1256/src/testdir/test_vim9_script.vim 2020-07-19 17:16:58.686848586 +0200 --- src/testdir/test_vim9_script.vim 2020-07-20 22:32:26.319013226 +0200 *************** *** 169,174 **** --- 169,186 ---- let somelist = rand() > 0 ? [1, 2, 3] : ['a', 'b', 'c'] enddef + def Test_assignment_list_vim9script() + let lines =<< trim END + vim9script + let v1: number + let v2: number + let v3: number + [v1, v2, v3] = [1, 2, 3] + assert_equal([1, 2, 3], [v1, v2, v3]) + END + call CheckScriptSuccess(lines) + enddef + def Test_assignment_dict() let dict1: dict = #{one: false, two: true} let dict2: dict = #{one: 1, two: 2} *** ../vim-8.2.1256/src/version.c 2020-07-20 22:09:31.658114755 +0200 --- src/version.c 2020-07-20 22:33:03.954917656 +0200 *************** *** 756,757 **** --- 756,759 ---- { /* Add new patch number below this line */ + /**/ + 1257, /**/ -- hundred-and-one symptoms of being an internet addict: 49. You never have to deal with busy signals when calling your ISP...because you never log off. /// 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 ///