aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/nvim/viml/executor/converter.c2
-rw-r--r--test/functional/lua_spec.lua27
2 files changed, 20 insertions, 9 deletions
diff --git a/src/nvim/viml/executor/converter.c b/src/nvim/viml/executor/converter.c
index c127b87738..319e07bdbc 100644
--- a/src/nvim/viml/executor/converter.c
+++ b/src/nvim/viml/executor/converter.c
@@ -446,7 +446,7 @@ bool nlua_pop_typval(lua_State *lstate, typval_T *ret_tv)
? (void *)mpval.data.d.dict == (void *)(val) \
: (void *)mpval.data.l.list == (void *)(val)) { \
lua_pushvalue(lstate, \
- 1 - ((int)((kv_size(*mpstack) - backref + 1) * 2))); \
+ -((int)((kv_size(*mpstack) - backref + 1) * 2))); \
break; \
} \
} \
diff --git a/test/functional/lua_spec.lua b/test/functional/lua_spec.lua
index 4f00189519..5c6dee90a3 100644
--- a/test/functional/lua_spec.lua
+++ b/test/functional/lua_spec.lua
@@ -224,12 +224,23 @@ describe('luaeval() function', function()
eq(10, funcs.luaeval('vim.api._vim_id({[vim.type_idx]=vim.types.float, [vim.val_idx]=10, [5]=1, foo=2, [1]=42})'))
end)
-- TODO: check what happens when it errors out on second list item
---[[FIXME
- [
- [ it('correctly converts self-containing containers', function()
- [ meths.set_var('l', {})
- [ eval('add(l, l)')
- [ eq(true, eval('luaeval("_A == _A[1]", l)'))
- [ end)
- ]]
+ -- TODO: check what happens if API function receives wrong number of
+ -- arguments.
+ -- TODO: check what happens if API function receives wrong argument types.
+
+ it('correctly converts self-containing containers', function()
+ meths.set_var('l', {})
+ eval('add(l, l)')
+ eq(true, eval('luaeval("_A == _A[1]", l)'))
+ eq(true, eval('luaeval("_A[1] == _A[1][1]", [l])'))
+ eq(true, eval('luaeval("_A.d == _A.d[1]", {"d": l})'))
+ eq(true, eval('luaeval("_A ~= _A[1]", [l])'))
+
+ meths.set_var('d', {foo=42})
+ eval('extend(d, {"d": d})')
+ eq(true, eval('luaeval("_A == _A.d", d)'))
+ eq(true, eval('luaeval("_A[1] == _A[1].d", [d])'))
+ eq(true, eval('luaeval("_A.d == _A.d.d", {"d": d})'))
+ eq(true, eval('luaeval("_A ~= _A.d", {"d": d})'))
+ end)
end)