luau icon indicating copy to clipboard operation
luau copied to clipboard

[new solver] Refinement of generic key in table key assignment breaks

Open deviaze opened this issue 5 months ago • 0 comments

Using latest version of luau-lsp.

function tt.select<K, V>(t: { [K]: V }, columns: { K }): { [K]: V }
    local result = {}
    if tt.caniteratenormally(t) then
        for k, v in t do
            if table.find(columns, k) then
                result[k] = v -- TypeError: Type function instance refine<intersect<K, ~nil>, *no-refine*> is uninhabited
            end
        end
    else
        for k, v in pairs(t) do
            if table.find(columns, k) then
                result[k] = v
            end
        end
    end
    return result
end

deviaze avatar Jul 08 '25 18:07 deviaze