Skip to content

Unknown type when dividing two numbers (2) #2236

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

Open
RomanSpector opened this issue Jul 28, 2023 · 3 comments
Open

Unknown type when dividing two numbers (2) #2236

RomanSpector opened this issue Jul 28, 2023 · 3 comments
Labels
bug Something isn't working feat/type check Related to the type checking feature

Comments

@RomanSpector
Copy link

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

Expected Behaviour

image

Actual Behaviour

image

image

image

Reproduction steps

local count = 0;
local time = 0;
local allcount = 0;
local alltime = 0;
local avg = 0;

---@type integer[]
local allstats = {}

for i, value in ipairs(allstats) do
    count     = count + 1;
    time      = time + 1;
    allcount  = allcount + 1;
    alltime   = alltime + 1;
end

if allcount > 0 then
   avg = alltime / allcount;
end

Additional Notes

Previous fix: #2036

Log File

No response

@carsakiller
Copy link
Collaborator

That is very odd. If you remove the for loop, it seems to work just fine. Also, if you just comment out allcount = allcount + 1, the if statement has the correct type, but the line under it says allcount: unknown.

@carsakiller carsakiller added bug Something isn't working feat/type check Related to the type checking feature labels Aug 4, 2023
@RomanSpector
Copy link
Author

up

@RomanSpector
Copy link
Author

After the 3.9.0 update, the problem worsened

2024-05-12.095001.mp4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working feat/type check Related to the type checking feature
Projects
None yet
Development

No branches or pull requests

2 participants