lua-language-server
lua-language-server copied to clipboard
Undefined global `var` in a function which has injected `var` into env
Describe the bug
luv -v: LuaJIT 2.1.0-beta3 -- Copyright (C) 2005-2022 Mike Pall. https://luajit.org/
local A = {}
function A.sync(executor)
local env = getfenv(executor)
env.await = A.wait
-- ......
executor()
end
function A.wait(promise)
print('go')
end
A.sync(function()
await() -- Undefined global `await`.
end)
return A
Expected behavior
No Undefined global
If it's hard to fix, how can I trick the server into treating awati as a global variable but not become an item in completion outside the executor function.
Have no way for now.