diff src/eval.c @ 24760:ca0f983f08cf v8.2.2918

patch 8.2.2918: builtin function can be shadowed by global variable Commit: https://github.com/vim/vim/commit/3d9c4eefe656ee8bf58c0496a48bd56bac180056 Author: Bram Moolenaar <Bram@vim.org> Date: Mon May 31 22:15:26 2021 +0200 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)
author Bram Moolenaar <Bram@vim.org>
date Mon, 31 May 2021 22:30:02 +0200
parents bf8feac8a89a
children 3907cf9be745
line wrap: on
line diff
--- a/src/eval.c
+++ b/src/eval.c
@@ -1462,6 +1462,13 @@ set_var_lval(
 		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);