Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vim.iter: flatten() non-list input #28448

Closed
justinmk opened this issue Apr 21, 2024 · 1 comment
Closed

vim.iter: flatten() non-list input #28448

justinmk opened this issue Apr 21, 2024 · 1 comment
Labels
complexity:low Low-risk, self-contained. Do NOT ask "can I work on this", just read CONTRIBUTING.md enhancement feature request lua stdlib
Milestone

Comments

@justinmk
Copy link
Member

justinmk commented Apr 21, 2024

Problem

iter:flatten() currently fails ("flatten() requires a list-like table") on this code from gen_lsp.lua:

neovim/scripts/gen_lsp.lua

Lines 262 to 265 in 35e3883

local anonym = vim.tbl_flatten { -- remove nil
anonymous_num > 1 and '' or nil,
'---@class ' .. anonymous_classname,
}

local anonym = vim.iter({ -- remove nil
  anonymous_num > 1 and '' or nil,
  '---@class ' .. anonymous_classname,
}):flatten():totable()

Expected behavior

tbl_flatten accepted array-like input and the above gen_lsp code leveraged that to drop nil items.

Can we enhance Iter:flatten() to work for arrays?

@justinmk justinmk added enhancement feature request lua stdlib complexity:low Low-risk, self-contained. Do NOT ask "can I work on this", just read CONTRIBUTING.md labels Apr 21, 2024
@justinmk justinmk added this to the backlog milestone Apr 21, 2024
@justinmk justinmk added the needs:discussion For PRs that propose significant changes to some part of the architecture or API label Apr 22, 2024
@clason
Copy link
Member

clason commented May 17, 2024

Duplicate of #28777 (which has more information and will be closed by #28781)

@clason clason closed this as not planned Won't fix, can't repro, duplicate, stale May 17, 2024
@justinmk justinmk removed the needs:discussion For PRs that propose significant changes to some part of the architecture or API label May 17, 2024
@justinmk justinmk modified the milestones: backlog, 0.11 May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
complexity:low Low-risk, self-contained. Do NOT ask "can I work on this", just read CONTRIBUTING.md enhancement feature request lua stdlib
Projects
None yet
Development

No branches or pull requests

2 participants