mirror of
https://github.com/vim/vim.git
synced 2025-09-23 03:43:49 -04:00
patch 8.2.2918: builtin function can be shadowed by global variable
Problem: Builtin function can be shadowed by global variable. Solution: Check for builtin function before variable. (Yasuhiro Matsumoto, closes #8302)
This commit is contained in:
@@ -1462,6 +1462,13 @@ set_var_lval(
|
|||||||
semsg(_(e_dictkey), lp->ll_newkey);
|
semsg(_(e_dictkey), lp->ll_newkey);
|
||||||
return;
|
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.
|
// Need to add an item to the Dictionary.
|
||||||
di = dictitem_alloc(lp->ll_newkey);
|
di = dictitem_alloc(lp->ll_newkey);
|
||||||
|
@@ -2681,4 +2681,12 @@ func Test_gettext()
|
|||||||
call assert_fails('call gettext(1)', 'E475:')
|
call assert_fails('call gettext(1)', 'E475:')
|
||||||
endfunc
|
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: shiftwidth=2 sts=2 expandtab
|
||||||
|
@@ -750,6 +750,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
2918,
|
||||||
/**/
|
/**/
|
||||||
2917,
|
2917,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user