Open
Description
In some cases you might need to make the plugin recognize a specific local variable as global, without declaring that variable as an actual global, one of these cases are using load
and loadfile
were you can pass an env
variable that represents the chunk environment.
*mainFile.lua
local env = setmetatable(
{foo = function(a, b) return a == b end},
{__index = _G}
)
loadfile('./secondFile.lua', 't', env)
*secondFile.lua
foo(1, 2) -- Undefined global `foo` . Lua Diagnostics.(undefined-global)
So i would suggest better recognizing for load
/loadfile
/loadstring
environment or/and a custom emmylua annotations --- @global
that marks the local var as a global one.
Thanks in advance.