aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/eval.c
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2024-02-18 19:11:44 +0800
committerGitHub <noreply@github.com>2024-02-18 19:11:44 +0800
commitb8c34efe3399b0786a0e00012cfa3a05a4aa4654 (patch)
tree5cf06572e1aa937f048faec77c63bc4e98837152 /src/nvim/eval.c
parent796df966f3cb83698035b85522504d40e7b5ab0b (diff)
downloadrneovim-b8c34efe3399b0786a0e00012cfa3a05a4aa4654.tar.gz
rneovim-b8c34efe3399b0786a0e00012cfa3a05a4aa4654.tar.bz2
rneovim-b8c34efe3399b0786a0e00012cfa3a05a4aa4654.zip
fix(eval): skip over v:lua properly (#27517)
Problem: Error when parsing v:lua in a ternary expression. Solution: Set rettv->v_type for v:lua even if not evaluating.
Diffstat (limited to 'src/nvim/eval.c')
-rw-r--r--src/nvim/eval.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index 4734e46362..3d224bfa0f 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -3238,6 +3238,13 @@ static int eval7(char **arg, typval_T *rettv, evalarg_T *const evalarg, bool wan
} else {
// skip the name
check_vars(s, (size_t)len);
+ // If evaluate is false rettv->v_type was not set, but it's needed
+ // in handle_subscript() to parse v:lua, so set it here.
+ if (rettv->v_type == VAR_UNKNOWN && !evaluate && strnequal(s, "v:lua.", 6)) {
+ rettv->v_type = VAR_PARTIAL;
+ rettv->vval.v_partial = vvlua_partial;
+ rettv->vval.v_partial->pt_refcount++;
+ }
ret = OK;
}
}
@@ -3442,7 +3449,7 @@ static int eval_method(char **const arg, typval_T *const rettv, evalarg_T *const
int len;
char *name = *arg;
char *lua_funcname = NULL;
- if (strncmp(name, "v:lua.", 6) == 0) {
+ if (strnequal(name, "v:lua.", 6)) {
lua_funcname = name + 6;
*arg = (char *)skip_luafunc_name(lua_funcname);
*arg = skipwhite(*arg); // to detect trailing whitespace later
@@ -7614,6 +7621,10 @@ int handle_subscript(const char **const arg, typval_T *rettv, evalarg_T *const e
const char *lua_funcname = NULL;
if (tv_is_luafunc(rettv)) {
+ if (!evaluate) {
+ tv_clear(rettv);
+ }
+
if (**arg != '.') {
tv_clear(rettv);
ret = FAIL;