lua-language-server
                                
                                 lua-language-server copied to clipboard
                                
                                    lua-language-server copied to clipboard
                            
                            
                            
                        Can not infer basic assignments in nested loop.
Discussed in https://github.com/LuaLS/lua-language-server/discussions/2471
Originally posted by Luke100000 January 8, 2024 Why can it not infer the type here? How would I rewrite this to be type conform, without spamming type annotations?
local y = 0
for i = 1, 2 do
    y = y + 1 -- here, y is inferred as an integer correctly
    for j = 1, 2 do
        y = y + 1 -- can not infer type
    end
    -- sometimes a bit more complexity is required to trigger the issue, so lets add another loop
    for j = 1, 2 do
        y = y + 1 -- can not infer type
    end
end
print(y)
https://github.com/LuaLS/lua-language-server/issues/2236