LuaLS / LuaLS/lua-language-server
Register function environment variables
Ninguém assumiu esta issue ainda.
- Linguagem predominante
- Lua
- Estrelas
- 4.4k
- Forks
- 442
- Métricas de merge de PRs
- Nenhum PR com merge em 30d
Descrição
This extension is able to detect usage of undefined global variables:

However, setfenv is used on this function to define the missing variable, but at another point in the code that the parser can't detect. Is it possible to somehow tell the parser to ignore this diagnostic? Something like:
local block = function(_)
-- env: {block, assert, error}
block()
end
Then it would accept those values? I know you can define globals for the project, but this doesn't affect the entire project, only those functions, so it would be cool if you could define it somehow.
Alternatively, could we just disable the diagnostic?
local block = function(_)
-- disable: undefined-global
block()
end
I don't know if the parser supports reading comments like that, let me know if that won't work or if you have better ideas for it.
Guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Direção de pesquisa
Comece rastreando o diagnóstico de global indefinido do parser e como ele lê as definições de globais no nível do projeto. Avalie a anotação de ambiente local da função e o comentário para desabilitar o diagnóstico propostos na issue e, em seguida, verifique se a sintaxe selecionada suprime ou resolve apenas o aviso pretendido no escopo da função.
Escrita pelo modelo de indexação a partir do texto da issue.
Avaliação
- Stack de tecnologia
- lua
- Domínio
- devtools
- Tipo de issue
- Funcionalidade
- Dificuldade
- 4/5
- Tempo estimado
- 3-5 dias
- Status de atividade
- Estagnada
- Clareza
- Razoavelmente clara
- Facilidade para iniciantes
- 35/100