To: vim_dev@googlegroups.com Subject: Patch 8.2.1502 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.1502 Problem: Vim9: can use += with a :let command at script level. Solution: Give an error. Files: src/evalvars.c, src/testdir/test_vim9_script.vim, src/testdir/test_vim9_expr.vim *** ../vim-8.2.1501/src/evalvars.c 2020-08-19 21:20:46.089038670 +0200 --- src/evalvars.c 2020-08-21 21:30:44.299360070 +0200 *************** *** 786,792 **** op[1] = NUL; if (*expr != '=') { ! if (vim_strchr((char_u *)"+-*/%.", *expr) != NULL) { op[0] = *expr; // +=, -=, *=, /=, %= or .= ++len; --- 786,798 ---- op[1] = NUL; if (*expr != '=') { ! if (vim9script && (flags & LET_NO_COMMAND) == 0) ! { ! // +=, /=, etc. require an existing variable ! semsg(_(e_cannot_use_operator_on_new_variable), eap->arg); ! i = FAIL; ! } ! else if (vim_strchr((char_u *)"+-*/%.", *expr) != NULL) { op[0] = *expr; // +=, -=, *=, /=, %= or .= ++len; *** ../vim-8.2.1501/src/testdir/test_vim9_script.vim 2020-08-20 23:04:03.103928227 +0200 --- src/testdir/test_vim9_script.vim 2020-08-21 21:31:29.867134805 +0200 *************** *** 569,575 **** call CheckDefFailure(['let t:var = 5'], 'E1016: Cannot declare a tab variable:') call CheckDefFailure(['let anr = 4', 'anr ..= "text"'], 'E1019:') ! call CheckDefFailure(['let xnr += 4'], 'E1020:') call CheckScriptFailure(['vim9script', 'def Func()', 'let dummy = s:notfound', 'enddef', 'defcompile'], 'E1108:') --- 569,578 ---- call CheckDefFailure(['let t:var = 5'], 'E1016: Cannot declare a tab variable:') call CheckDefFailure(['let anr = 4', 'anr ..= "text"'], 'E1019:') ! call CheckDefFailure(['let xnr += 4'], 'E1020:', 1) ! call CheckScriptFailure(['vim9script', 'let xnr += 4'], 'E1020:') ! call CheckDefFailure(["let xnr = xnr + 1"], 'E1001:', 1) ! call CheckScriptFailure(['vim9script', 'let xnr = xnr + 4'], 'E121:') call CheckScriptFailure(['vim9script', 'def Func()', 'let dummy = s:notfound', 'enddef', 'defcompile'], 'E1108:') *** ../vim-8.2.1501/src/testdir/test_vim9_expr.vim 2020-08-21 20:43:13.197523686 +0200 --- src/testdir/test_vim9_expr.vim 2020-08-21 21:26:52.220522261 +0200 *************** *** 1682,1689 **** call CheckDefFailure(["let x = {xxx: 8}"], 'E1001:', 1) call CheckDefFailure(["let x = #{a: 1, a: 2}"], 'E721:', 1) call CheckDefFailure(["let x = #"], 'E1015:', 1) - call CheckDefFailure(["let x += 1"], 'E1020:', 1) - call CheckDefFailure(["let x = x + 1"], 'E1001:', 1) call CheckDefExecFailure(["let x = g:anint.member"], 'E715:', 1) call CheckDefExecFailure(["let x = g:dict_empty.member"], 'E716:', 1) --- 1682,1687 ---- *** ../vim-8.2.1501/src/version.c 2020-08-21 20:43:13.201523666 +0200 --- src/version.c 2020-08-21 21:32:05.274960355 +0200 *************** *** 756,757 **** --- 756,759 ---- { /* Add new patch number below this line */ + /**/ + 1502, /**/ -- Place mark here ->[ ]<- if you want a dirty monitor. /// 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 ///