mirror of
https://github.com/neovim/neovim.git
synced 2026-08-28 18:11:47 +00:00
Merge pull request #40475 from bfredl/vim.NIL
fix(lua): give nicer error message when trying to index vim.NIL
This commit is contained in:
@@ -676,6 +676,10 @@ static void nlua_common_vim_init(lua_State *lstate, bool is_thread)
|
||||
lua_createtable(lstate, 0, 0);
|
||||
lua_pushcfunction(lstate, &nlua_nil_tostring);
|
||||
lua_setfield(lstate, -2, "__tostring");
|
||||
lua_pushcfunction(lstate, &nlua_nil_index);
|
||||
lua_setfield(lstate, -2, "__index");
|
||||
lua_pushcfunction(lstate, &nlua_nil_index);
|
||||
lua_setfield(lstate, -2, "__newindex");
|
||||
lua_setmetatable(lstate, -2);
|
||||
ref_state->nil_ref = nlua_ref(lstate, ref_state, -1);
|
||||
lua_pushvalue(lstate, -1);
|
||||
@@ -1395,6 +1399,11 @@ static int nlua_nil_tostring(lua_State *lstate)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int nlua_nil_index(lua_State *lstate)
|
||||
{
|
||||
return luaL_error(lstate, "attempt to index vim.NIL");
|
||||
}
|
||||
|
||||
static int nlua_empty_dict_tostring(lua_State *lstate)
|
||||
{
|
||||
lua_pushstring(lstate, "vim.empty_dict()");
|
||||
|
||||
Reference in New Issue
Block a user