Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alias of an array of itself causing stack overflow when providing completion #1717

Closed
JanSharp opened this issue Nov 20, 2022 · 0 comments
Closed
Labels
bug Something isn't working

Comments

@JanSharp
Copy link
Contributor

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?

Annotations, Completion

Expected Behaviour

When having an alias like ---@alias Foo (string|Foo)[] it should understand that { "hello", "world"} or {"hello", {"wordl"}} are both matching that type. That's actually about type checking, which is not the focus of this issue/bug report, see below.

Actual Behaviour

The server errors due to a stack overflow when trying to provide completion inside of a table constructor that is assigned to a variable of type Foo. The error is:

[01:04:07.826][error][#0:script/workspace/scope.lua:58]: script/workspace/scope.lua:58: stack overflow
stack traceback:
	script/workspace/scope.lua:58: in method 'isChildUri'
	script/workspace/scope.lua:216: in function 'workspace.scope.getFolder'
	script/workspace/scope.lua:243: in function 'workspace.scope.getScope'
	script/vm/global.lua:51: in method 'getSets'
	script/vm/def.lua:50: in upvalue 'searchByNode'
	script/vm/def.lua:91: in function 'vm.vm.getDefs'
	script/core/completion/completion.lua:1276: in upvalue 'insertEnum'
	script/core/completion/completion.lua:1277: in upvalue 'insertEnum'
	script/core/completion/completion.lua:1277: in upvalue 'insertEnum'
	script/core/completion/completion.lua:1277: in upvalue 'insertEnum'
	...	(skipping 83317 levels)
	script/core/completion/completion.lua:1277: in upvalue 'insertEnum'
	script/core/completion/completion.lua:1277: in upvalue 'insertEnum'
	script/core/completion/completion.lua:1291: in upvalue 'checkTypingEnum'
	script/core/completion/completion.lua:1309: in upvalue 'checkEqualEnumLeft'
	script/core/completion/completion.lua:1354: in upvalue 'checkEqualEnumInString'
	script/core/completion/completion.lua:1384: in upvalue 'trySpecial'
	script/core/completion/completion.lua:2229: in upvalue 'tryCompletions'
	script/core/completion/completion.lua:2248: in function 'core.completion.completion.completion'
	script/provider/provider.lua:638: in function <script/provider/provider.lua:601>
	[C]: in function 'xpcall'
	script/proto/proto.lua:184: in function <script/proto/proto.lua:159>

Reproduction steps

  1. put this code somewhere
---@alias Foo Foo[]
---@type Foo
local foo
foo = {""}
  1. put the cursor inside of ""
  2. press space bar
  3. wait a second
  4. see error

Additional Notes

language server version: 3.6.3 (even though the log file says 3.5.3, I've got a stupid setup. I can guarantee I'm on 3.6.3)

The real world example is ---@alias LocalisedString string|number|boolean|LuaObject|nil|(string|LocalisedString)[] for Factorio. ---@alias Foo Foo[] is just the minimal reproduction case.

Log File

file_mnt_big_temp_ls_crash_minimal.log

@sumneko sumneko added the bug Something isn't working label Nov 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants