-
-
Couldn't load subscription status.
- Fork 384
Closed
Description
How are you using the lua-language-server?
Visual Studio Code Extension (sumneko.lua)
Which OS are you using?
Linux
What is the issue affecting?
Type Checking, Annotations, Hover
Expected Behaviour
- Aliases (especially recursive) are not expanded in hover tips.
- The language server does not crash and stays responsive even when some aliases are recursive.
Actual Behaviour
- Recursive aliases get expanded recursively. This behavior in hover tips is not helpful at all because it gets very hard to understand the types.
2. The language server produces "stack overflow" errors in the output and freezes for a few seconds on every file save. Linting and format-on-save become very slow and annoying. Also, file saving does not work 100% of the time.
Reproduction steps
- Create a file with the code:
---@alias Tree
---| { parent: Tree|nil, type: "leaf", [1]: string }
---| { parent: Tree|nil, type: "node", [1]: Tree, [2]: Tree }
---@param t Tree
---@return Tree
local function do_something(t)
if t.type == "leaf" then
return t
elseif t.type == "node" and #t == 1 then
table.insert(t, { type = "leaf", "b" })
return t
else
return t
end
end
local function main()
local leaf = { type = "leaf", "a" }
local node = { type = "node", leaf }
leaf.parent = node
print(do_something(node))
end
main()- Try to make a small change, e.g. add some spaces after
returninreturn tand save the changes. The saving and format-on-save are largely delayed and the server produces the error log provided below. - Try hovering the
Treein@param t Tree. The hover tip is recursively expanded and messy as shown above.
Additional Notes
I really need to create recursive data types like trees and doubly-linked lists in my code, but just using an @alias like that gets tedious with the current language server version. If there is a simple workaround, I would love to use that.
Log File
Metadata
Metadata
Assignees
Labels
No labels