lua-language-server icon indicating copy to clipboard operation
lua-language-server copied to clipboard

Unknown type when dividing two numbers (2)

Open RomanSpector opened this issue 2 years ago • 3 comments

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: https://github.com/LuaLS/lua-language-server/issues/2036

Log File

No response

RomanSpector avatar Jul 28 '23 15:07 RomanSpector

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 avatar Jul 28 '23 16:07 carsakiller

up

RomanSpector avatar Sep 14 '23 07:09 RomanSpector

After the 3.9.0 update, the problem worsened

https://github.com/LuaLS/lua-language-server/assets/57856647/82e338eb-b3dd-47c6-848d-bee445cf5598

RomanSpector avatar May 12 '24 06:05 RomanSpector