LuaLS / LuaLS/lua-language-server
Undefined global `var` in a function which has injected `var` into env
Nobody has claimed this yet.
- Dominant language
- Lua
- Stars
- 4.4k
- Forks
- 442
- PR merge metrics
- No merged PRs in 30d
Description
**Describe the bug**
`luv -v`: `LuaJIT 2.1.0-beta3 -- Copyright (C) 2005-2022 Mike Pall. https://luajit.org/`
```lua
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the report with the Lua example in a running Lua language server and inspect how the analyzer handles getfenv, injected environment members, and global diagnostics. No source file or test is named in the issue, so first locate the relevant global-analysis and completion entry points. Done means await is not reported as undefined inside the executor while remaining absent from completion outside it.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- lua
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100