To: vim_dev@googlegroups.com Subject: Patch 8.2.3841 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.3841 Problem: Vim9: outdated TODO items, disabled tests that work. Solution: Remove TODO items, run tests that work now. Check that a dict item isn't locked. Files: src/vim9execute.c, src/evalvars.c, src/errors.h, src/globals.h, src/testdir/test_listdict.vim, src/testdir/test_vim9_assign.vim *** ../vim-8.2.3840/src/vim9execute.c 2021-12-16 20:56:52.956098576 +0000 --- src/vim9execute.c 2021-12-17 20:05:37.261050924 +0000 *************** *** 915,921 **** // The function has been compiled, can call it quickly. For a function // that was defined later: we can call it directly next time. - // TODO: what if the function was deleted and then defined again? if (iptr != NULL) { delete_instr(iptr); --- 915,920 ---- *************** *** 933,939 **** funcexe.fe_selfdict = selfdict != NULL ? selfdict : dict_stack_get_dict(); // Call the user function. Result goes in last position on the stack. - // TODO: add selfdict if there is one error = call_user_func_check(ufunc, argcount, argvars, STACK_TV_BOT(-1), &funcexe, funcexe.fe_selfdict); --- 932,937 ---- *************** *** 2862,2882 **** char_u *key = tv_idx->vval.v_string; dictitem_T *di = NULL; ! if (key == NULL) ! key = (char_u *)""; ! if (d != NULL) ! di = dict_find(d, key, (int)STRLEN(key)); ! if (di == NULL) ! { ! // NULL dict is equivalent to empty dict ! SOURCING_LNUM = iptr->isn_lnum; ! semsg(_(e_dictkey), key); status = FAIL; - } else { ! // TODO: check for dict or item locked ! dictitem_remove(d, di); } } } --- 2860,2888 ---- char_u *key = tv_idx->vval.v_string; dictitem_T *di = NULL; ! if (d != NULL && value_check_lock( ! d->dv_lock, NULL, FALSE)) status = FAIL; else { ! SOURCING_LNUM = iptr->isn_lnum; ! if (key == NULL) ! key = (char_u *)""; ! if (d != NULL) ! di = dict_find(d, key, (int)STRLEN(key)); ! if (di == NULL) ! { ! // NULL dict is equivalent to empty dict ! semsg(_(e_dictkey), key); ! status = FAIL; ! } ! else if (var_check_fixed(di->di_flags, ! NULL, FALSE) ! || var_check_ro(di->di_flags, ! NULL, FALSE)) ! status = FAIL; ! else ! dictitem_remove(d, di); } } } *** ../vim-8.2.3840/src/evalvars.c 2021-12-16 20:56:52.952098567 +0000 --- src/evalvars.c 2021-12-17 20:11:49.500519222 +0000 *************** *** 2314,2320 **** } if (sandbox && (vimvars[idx].vv_flags & VV_RO_SBX)) { ! semsg(_(e_readonlysbx), vimvars[idx].vv_name); return FAIL; } clear_tv(&vimvars[idx].vv_di.di_tv); --- 2314,2320 ---- } if (sandbox && (vimvars[idx].vv_flags & VV_RO_SBX)) { ! semsg(_(e_cannot_set_variable_in_sandbox_str), vimvars[idx].vv_name); return FAIL; } clear_tv(&vimvars[idx].vv_di.di_tv); *************** *** 3610,3622 **** { if (flags & DI_FLAGS_RO) { ! semsg(_(e_cannot_change_readonly_variable_str), use_gettext ? (char_u *)_(name) : name); return TRUE; } if ((flags & DI_FLAGS_RO_SBX) && sandbox) { ! semsg(_(e_readonlysbx), use_gettext ? (char_u *)_(name) : name); return TRUE; } return FALSE; --- 3610,3629 ---- { if (flags & DI_FLAGS_RO) { ! if (name == NULL) ! emsg(_(e_cannot_change_readonly_variable)); ! else ! semsg(_(e_cannot_change_readonly_variable_str), use_gettext ? (char_u *)_(name) : name); return TRUE; } if ((flags & DI_FLAGS_RO_SBX) && sandbox) { ! if (name == NULL) ! emsg(_(e_cannot_set_variable_in_sandbox)); ! else ! semsg(_(e_cannot_set_variable_in_sandbox_str), ! use_gettext ? (char_u *)_(name) : name); return TRUE; } return FALSE; *************** *** 3647,3653 **** { if (flags & DI_FLAGS_FIX) { ! semsg(_("E795: Cannot delete variable %s"), use_gettext ? (char_u *)_(name) : name); return TRUE; } --- 3654,3663 ---- { if (flags & DI_FLAGS_FIX) { ! if (name == NULL) ! emsg(_(e_cannot_delete_variable)); ! else ! semsg(_(e_cannot_delete_variable_str), use_gettext ? (char_u *)_(name) : name); return TRUE; } *************** *** 3696,3713 **** { if (lock & VAR_LOCKED) { ! semsg(_("E741: Value is locked: %s"), ! name == NULL ? (char_u *)_("Unknown") ! : use_gettext ? (char_u *)_(name) ! : name); return TRUE; } if (lock & VAR_FIXED) { ! semsg(_("E742: Cannot change value of %s"), ! name == NULL ? (char_u *)_("Unknown") ! : use_gettext ? (char_u *)_(name) ! : name); return TRUE; } return FALSE; --- 3706,3725 ---- { if (lock & VAR_LOCKED) { ! if (name == NULL) ! emsg(_(e_value_is_locked)); ! else ! semsg(_(e_value_is_locked_str), ! use_gettext ? (char_u *)_(name) : name); return TRUE; } if (lock & VAR_FIXED) { ! if (name == NULL) ! emsg(_(e_cannot_change_value)); ! else ! semsg(_(e_cannot_change_value_of_str), ! use_gettext ? (char_u *)_(name) : name); return TRUE; } return FALSE; *** ../vim-8.2.3840/src/errors.h 2021-12-16 20:56:52.948098558 +0000 --- src/errors.h 2021-12-17 20:10:47.920378859 +0000 *************** *** 105,110 **** --- 105,112 ---- EXTERN char e_readonly_option_is_set_add_bang_to_override[] INIT(= N_("E45: 'readonly' option is set (add ! to override)")); #ifdef FEAT_EVAL + EXTERN char e_cannot_change_readonly_variable[] + INIT(= N_("E46: Cannot change read-only variable")); EXTERN char e_cannot_change_readonly_variable_str[] INIT(= N_("E46: Cannot change read-only variable \"%s\"")); #endif *************** *** 290,295 **** --- 292,313 ---- INIT(= N_("E711: List value does not have enough items")); EXTERN char e_cannot_slice_dictionary[] INIT(= N_("E719: Cannot slice a Dictionary")); + EXTERN char e_value_is_locked[] + INIT(= N_("E741: Value is locked")); + EXTERN char e_value_is_locked_str[] + INIT(= N_("E741: Value is locked: %s")); + EXTERN char e_cannot_change_value[] + INIT(= N_("E742: Cannot change value")); + EXTERN char e_cannot_change_value_of_str[] + INIT(= N_("E742: Cannot change value of %s")); + EXTERN char e_cannot_set_variable_in_sandbox[] + INIT(= N_("E794: Cannot set variable in the sandbox")); + EXTERN char e_cannot_set_variable_in_sandbox_str[] + INIT(= N_("E794: Cannot set variable in the sandbox: \"%s\"")); + EXTERN char e_cannot_delete_variable[] + INIT(= N_("E795: Cannot delete variable")); + EXTERN char e_cannot_delete_variable_str[] + INIT(= N_("E795: Cannot delete variable %s")); #endif EXTERN char e_conflicts_with_value_of_listchars[] INIT(= N_("E834: Conflicts with value of 'listchars'")); *** ../vim-8.2.3840/src/globals.h 2021-12-16 20:56:52.948098558 +0000 --- src/globals.h 2021-12-17 20:09:43.828464219 +0000 *************** *** 1680,1686 **** EXTERN char e_letwrong[] INIT(= N_("E734: Wrong variable type for %s=")); EXTERN char e_illvar[] INIT(= N_("E461: Illegal variable name: %s")); EXTERN char e_cannot_mod[] INIT(= N_("E995: Cannot modify existing variable")); - EXTERN char e_readonlysbx[] INIT(= N_("E794: Cannot set variable in the sandbox: \"%s\"")); EXTERN char e_stringreq[] INIT(= N_("E928: String required")); EXTERN char e_numberreq[] INIT(= N_("E889: Number required")); EXTERN char e_boolreq[] INIT(= N_("E839: Bool required")); --- 1680,1685 ---- *** ../vim-8.2.3840/src/testdir/test_listdict.vim 2021-11-30 11:56:19.034972194 +0000 --- src/testdir/test_listdict.vim 2021-12-17 19:40:57.490697637 +0000 *************** *** 743,752 **** unlet d.a call assert_equal({'b': 100}, d) END ! " TODO: make this work in a :def function ! "call CheckLegacyAndVim9Success(lines) ! call CheckTransLegacySuccess(lines) ! call CheckTransVim9Success(lines) endfunc " filter() after lock on dict item --- 743,749 ---- unlet d.a call assert_equal({'b': 100}, d) END ! call CheckLegacyAndVim9Success(lines) endfunc " filter() after lock on dict item *************** *** 757,766 **** call filter(d, 'v:key != "a"') call assert_equal({'b': 100}, d) END ! " TODO: make this work in a :def function ! "call CheckLegacyAndVim9Success(lines) ! call CheckTransLegacySuccess(lines) ! call CheckTransVim9Success(lines) endfunc " map() after lock on dict --- 754,760 ---- call filter(d, 'v:key != "a"') call assert_equal({'b': 100}, d) END ! call CheckLegacyAndVim9Success(lines) endfunc " map() after lock on dict *************** *** 774,779 **** --- 768,784 ---- " This won't work in a :def function call CheckTransLegacySuccess(lines) call CheckTransVim9Success(lines) + + " For a :def function use a global dict. + let lines =<< trim END + let g:thedict = {'a': 77, 'b': 88} + lockvar 1 g:thedict + def Delkey() + unlet g:thedict.a + enddef + call Delkey() + END + call CheckScriptFailure(lines, 'E741:') endfunc " No extend() after lock on dict item *** ../vim-8.2.3840/src/testdir/test_vim9_assign.vim 2021-12-01 17:37:56.440650135 +0000 --- src/testdir/test_vim9_assign.vim 2021-12-17 20:06:05.252982918 +0000 *************** *** 2017,2022 **** --- 2017,2038 ---- 'defcompile', ], 'E1081:') + CheckScriptFailure([ + 'vim9script', + 'def Delcount(dict: dict)', + ' unlet dict.count', + 'enddef', + 'Delcount(v:)', + ], 'E742:') + + CheckScriptFailure([ + 'vim9script', + 'def DelChangedtick(dict: dict)', + ' unlet dict.changedtick', + 'enddef', + 'DelChangedtick(b:)', + ], 'E795:') + writefile(['vim9script', 'export var svar = 1234'], 'XunletExport.vim') var lines =<< trim END vim9script *** ../vim-8.2.3840/src/version.c 2021-12-17 18:01:27.273790315 +0000 --- src/version.c 2021-12-17 19:06:32.773592378 +0000 *************** *** 751,752 **** --- 751,754 ---- { /* Add new patch number below this line */ + /**/ + 3841, /**/ -- "I simultaneously try to keep my head in the clouds and my feet on the ground. Sometimes it's a stretch, though." -- Larry Wall /// 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 ///