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

[EmmyLua] incorrect annotations for hs.fnutils #309

Open
smackesey opened this issue Jan 4, 2024 · 0 comments
Open

[EmmyLua] incorrect annotations for hs.fnutils #309

smackesey opened this issue Jan 4, 2024 · 0 comments

Comments

@smackesey
Copy link

smackesey commented Jan 4, 2024

#240 added the EmmyLua spoon to generate EmmyLua annotations for hs modules. I am not sure if the logic used to generate annotations has gone out of date or there was always an issue, but I've noticed that many of the annotations for hs.fnutils are missing or incorrect. For example, here is the annotation for hs.fnutils.map:

-- Execute a function across a table (in arbitrary order) and collect the results
--
-- Parameters:
--  * table - A table; it can have both a list (or array) part and a hash (or dict) part
--  * fn - A function that accepts a single parameter (a table element). For the hash part, the values returned
--  from this function (if non-nil) will be assigned to the same key in the result list. For the array part, this function
--  behaves like `hs.fnutils.imap()` (i.e. `nil` results are discarded); however all keys, including integer keys after
--  a "hole" in `table`, will be iterated over.
--
-- Returns:
--  * A table containing the results of calling the function on every element in the table
--
-- Notes:
--  * If `table` is a pure array table (list-like) without "holes", use `hs.fnutils.imap()` if you need guaranteed in-order
--  processing and for better performance.
function M.map(table, fn, ...) end

This is interpreted by current versions of lua_language_server as a nil return value. You end up with tons of false positive diagnostics wherever hs.fnutils is used.

It is possible there is a similar issue with other hs.* modules, I haven't checked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant