Skip to content

@vararg causing invalid type inference of generics #542

@Cassolette

Description

@Cassolette

The emmylua annotation ---@vararg causes incorrect key-val type inference when using pairs() on a table

image

Reproduce

--- @diagnostic disable: unused-local, empty-block

--- @class MyType

--- @type table<number, MyType>
local tb = {}

--- @vararg string
function test(...)
    for key, val in pairs(tb) do  -- key, val has wrong type (string)
    end
end

function test_no_varargs(...)
    for key, val in pairs(tb) do  -- key, val has correct type
    end
end

Client
Windows VSCode

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions