To: vim_dev@googlegroups.com Subject: Patch 8.2.2918 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.2918 Problem: Builtin function can be shadowed by global variable. Solution: Check for builtin function before variable. (Yasuhiro Matsumoto, closes #8302) Files: src/eval.c, src/testdir/test_functions.vim *** ../vim-8.2.2917/src/eval.c 2021-05-28 21:06:04.628687341 +0200 --- src/eval.c 2021-05-31 21:59:49.437027664 +0200 *************** *** 1462,1467 **** --- 1462,1474 ---- semsg(_(e_dictkey), lp->ll_newkey); return; } + if ((lp->ll_tv->vval.v_dict == get_globvar_dict() + || lp->ll_tv->vval.v_dict == + &SCRIPT_ITEM(current_sctx.sc_sid)->sn_vars->sv_dict) + && (rettv->v_type == VAR_FUNC + || rettv->v_type == VAR_PARTIAL) + && var_wrong_func_name(lp->ll_newkey, TRUE)) + return; // Need to add an item to the Dictionary. di = dictitem_alloc(lp->ll_newkey); *** ../vim-8.2.2917/src/testdir/test_functions.vim 2021-05-25 20:13:56.316778428 +0200 --- src/testdir/test_functions.vim 2021-05-31 22:03:55.432319549 +0200 *************** *** 2681,2684 **** --- 2681,2692 ---- call assert_fails('call gettext(1)', 'E475:') endfunc + func Test_builtin_check() + call assert_fails('let g:["trim"] = {x -> " " .. x}', 'E704:') + call assert_fails('let g:.trim = {x -> " " .. x}', 'E704:') + call assert_fails('let s:["trim"] = {x -> " " .. x}', 'E704:') + call assert_fails('let s:.trim = {x -> " " .. x}', 'E704:') + endfunc + + " vim: shiftwidth=2 sts=2 expandtab *** ../vim-8.2.2917/src/version.c 2021-05-31 20:04:00.553171007 +0200 --- src/version.c 2021-05-31 22:15:07.542595589 +0200 *************** *** 752,753 **** --- 752,755 ---- { /* Add new patch number below this line */ + /**/ + 2918, /**/ -- Compilation process failed successfully. /// 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 ///