lua-language-server icon indicating copy to clipboard operation
lua-language-server copied to clipboard

Add support for `getmetatable`

Open jakitliang opened this issue 5 months ago • 2 comments

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)

jakitliang avatar May 21 '25 18:05 jakitliang