lua-language-server
lua-language-server copied to clipboard
Add support for `getmetatable`
Show case:
local a = {x = 111}
local mt = {__index = a, __metatable = a, k = 111}
local b = setmetatable({y = 2}, mt)
-- 1. Firstly, giving type info instead of an empty `table`
-- 2. `mt` have `__metatable`, so `c` is `a`
local c = getmetatable(b)
local mt1 = {__index = a, k = 111}
local d = setmetatable({z = 3}, mt1)
-- 1. Firstly, giving type info instead of an empty `table`
-- 2. `mt1` doesn't have `__metatable`, so `e` is `mt1`
local e = getmetatable(d)