Skip to content

Array for loop issue #895

@Yakehira

Description

@Yakehira
local t = {
  123,
  234,
  345,
}

---@param id number
function test(id) end

for i = 1, #t do
  test(t[i]) -- expected 'number' but found (123|234|345)?
end

can currently do this as workaround

---@type number[]
local t = {
  123,
  234,
  345,
}

or

test(t[i] --[[@as number]])

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions