luau icon indicating copy to clipboard operation
luau copied to clipboard

Nullable upvalue types are not refined in loops in new solver strict mode

Open nothing1649 opened this issue 10 months ago • 0 comments

As of version 0.661, type refinements do not work inside loops if the variable is an upvalue. Removing the loop or bringing the variable into the same scope fixes the issue, and this also occurs with while/repeat loops.

--!strict
local var:number? = nil
local function _(): ()
    for _ = 1, 1 do
        if var then
            math.sin(var) --TypeError: Type 'nil' could not be converted into 'number'
        end
    end
end

nothing1649 avatar Feb 17 '25 00:02 nothing1649