Skip to content

Add support for getmetatable #3192

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

jakitliang
Copy link

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant