Works:
local tt = setmetatable({ foo = 123, bar = 321 }, {})
-- typing `tt.` shows both 'foo' and 'bar' as suggestions
local a = tt.foo -- `a` is integer
Doesn't work:
local t = { foo = 123, bar = 321 }
local tt = setmetatable(t, {})
-- no suggestions show up when typing `tt.`
local a = tt.foo -- `a` is nil because `tt.foo` is unknown
I first came across this when using emmylua_ls with AwesomeWM and requiring the awful module, but it also occurs in simpler cases like the one above.
In AwesomeWM:
local awful = require('awful')
The only field in awful is a function__index() which isn't even valid.