We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 5ab3dc7 commit 445b298Copy full SHA for 445b298
tests/tables/main.lua
@@ -20,12 +20,19 @@ local mt =
20
__len = function() return 42 end,
21
__add = function(self, other) return make() end,
22
__tostring = function() return "foobar" end,
23
+ __metatable = "hidden"
24
}
25
26
make = function()
27
return setmetatable({}, mt)
28
end
29
30
+local empty = {}
31
+local emptyWithMt = setmetatable({}, {__index = {foo = "FOO"}})
32
+local emptyWithLenMt = setmetatable({}, {__len = function() return 42 end})
33
+local emptyWithBadLenMt = setmetatable({}, {__len = function() error("FUBAR") end})
34
+local emptyWithBadIndexMt = setmetatable({}, {__index = function(s, k) error("FUBAR") end})
35
+
36
local a = make()
37
local b = make()
38
print(#a) --0 in 5.1/jit, 42 in 5.2+
0 commit comments