lua-language-server icon indicating copy to clipboard operation
lua-language-server copied to clipboard

Undefined global `var` in a function which has injected `var` into env

Open kevinhwang91 opened this issue 3 years ago • 1 comments

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.

kevinhwang91 avatar May 17 '22 07:05 kevinhwang91

Have no way for now.

sumneko avatar May 24 '22 18:05 sumneko