luau
luau copied to clipboard
Nullable upvalue types are not refined in loops in new solver strict mode
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