LuaLS/lua-language-server-rust

unexpected undefined globals: `string`, `error`

Closed this issue · 9 comments

I create an isolated file with the following content

error(string.format("abc%d", 1))

and it complains

dev/undefined.lua|1 col 1| [Lua Diagnostics.](undefined-global):Undefined global `error`.
dev/undefined.lua|1 col 7| [Lua Diagnostics.](undefined-global):Undefined global `string`.
CppCXY commented

Did the original LuaLS have this issue?

nope, just opened with original LuaLS and it recognizes string & error (even shows correct docs)

worth noting: I have lazydev plugin with {library={path = "luvit-meta/library", words = {"vim%.uv"}}} as config

CppCXY commented

Maybe I need to update to the latest version, actually the current luals is only 3.11.

CppCXY commented

If it is not a platform that luals cannot support, I recommend directly using the original luals. This repository does not provide any improvement over the original luals.

it's 64bit debian, btw

CppCXY commented

Can you try the latest release version? It has been updated to 3.13.1 and maintains the same layout as luals.

it doesn't diagnose any errors in the isolated file now, but doing doc-symbol-at-point says it's a global undefined var. This is consistent with semantic tokens that show string and error as a variable, rather than a built-in

I tried in one of my neovim config files¹ and for (at least) string:

  • semantic token describes it as a regular var (not built-in)
  • documentation-at-point says it's a global, undefined var
  • diagnosed as an error that it's an undefined global (undefined-global), which doesn't happen in the isolated file

none of the above happen to vim, which is another built-in, provided by lazydev

¹: that means I'm using https://github.com/folke/lazydev.nvim

CppCXY commented

I realized I forgot to include a debugger.lua file.

I'll take a look at it later. I'm mainly busy with language server development and only spend some time on this project on Fridays.

If you are interested, you can try another language server that I developed.
https://github.com/[CppCXY/emmylua-analyzer-rust](https://github.com/CppCXY/emmylua-analyzer-rust)