patch 8.2.3314: behavior of exists() in a :def function is unpredictable
Problem: Behavior of exists() in a :def function is unpredictable.
Solution: Add exists_compiled().
diff --git a/src/evalfunc.c b/src/evalfunc.c
index 7006afa..95ae211 100644
--- a/src/evalfunc.c
+++ b/src/evalfunc.c
@@ -49,6 +49,7 @@
static void f_eval(typval_T *argvars, typval_T *rettv);
static void f_eventhandler(typval_T *argvars, typval_T *rettv);
static void f_execute(typval_T *argvars, typval_T *rettv);
+static void f_exists_compiled(typval_T *argvars, typval_T *rettv);
static void f_expand(typval_T *argvars, typval_T *rettv);
static void f_expandcmd(typval_T *argvars, typval_T *rettv);
static void f_feedkeys(typval_T *argvars, typval_T *rettv);
@@ -1329,6 +1330,8 @@
ret_string, f_exepath},
{"exists", 1, 1, FEARG_1, arg1_string,
ret_number_bool, f_exists},
+ {"exists_compiled", 1, 1, FEARG_1, arg1_string,
+ ret_number_bool, f_exists_compiled},
{"exp", 1, 1, FEARG_1, arg1_float_or_nr,
ret_float, FLOAT_FUNC(f_exp)},
{"expand", 1, 3, FEARG_1, arg3_string_bool_bool,
@@ -3626,6 +3629,12 @@
rettv->vval.v_number = n;
}
+ static void
+f_exists_compiled(typval_T *argvars UNUSED, typval_T *rettv UNUSED)
+{
+ emsg(_(e_exists_compiled_can_only_be_used_in_def_function));
+}
+
/*
* "expand()" function
*/