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

Missing Completion in For Loop #1887

Closed
firas-assaad opened this issue Feb 7, 2023 · 1 comment
Closed

Missing Completion in For Loop #1887

firas-assaad opened this issue Feb 7, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@firas-assaad
Copy link
Contributor

How are you using the lua-language-server?

Visual Studio Code Extension (sumneko.lua)

Which OS are you using?

Windows

What is the issue affecting?

Type Checking, Completion, Hover

Expected Behaviour

In the following example:

---@class A_Class
local A = { x = 5 }

function A:func()
    for i = 1, self.x do
        print(i)
    end

    self.y = 3
    self.y = self.y + 3
end

When hovering over self.x in the for loop or trying to use auto-completion there, I expect to get x as a suggestion with the type integer.

image

It should be exactly the same result as if the self.y = self.y + 3 line is commented out.

---@class A_Class
local A = { x = 5 }

function A:func()
    for i = 1, self.x do
        print(i)
    end

    self.y = 3
    --self.y = self.y + 3
end

Actual Behaviour

The type of self is lost, but only in the for statement. Auto completion doesn't suggest x either.

image

This only happens when the line self.y = self.y + 3 is not removed or commented out. If it is removed, everything works as expected.

Reproduction steps

  1. Try the code snippets above in VS Code in version 3.6.10 of the LuaLS extension.

Additional Notes

No response

Log File

Let me know if you need it.

@sumneko sumneko added the bug Something isn't working label Feb 7, 2023
@JC0P
Copy link

JC0P commented Feb 7, 2023

'self.y = self.y + 3'

If you use this without enough values to go off of it won't work. Try adding more values for it to go along with.

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

3 participants