Skip to content

Conversation

@C3pa
Copy link
Contributor

@C3pa C3pa commented May 12, 2022

I used the technical descriptions from LuaJIT's official documentation.

Summary of changes:

  • Added the annotations to the meta/template/table.lua
  • Added the descriptions to all the locale files. All of them are in English though, so I left -- TODO: need translate! comments.
  • Removed those annotations from the OpenResty library annotations.
@C3pa
Copy link
Contributor Author

C3pa commented May 12, 2022

This addresses the issue #1118

---@deprecated
function table.getn(list) end

---@version JIT
Copy link
Contributor

@flrgh flrgh May 12, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a question. So, in OpenResty libraries, it's very common to see code that does this:

-- require the `table.new` function and stash it in a local  local new_table = require "table.new" -- ...now use the local function to create a table  local my_table = new_table(0, 5)

Examples:

Whether or not this is common elsewhere, in OpenResty it's considered idiomatic, largely because one is not relying on the side effect of modifying _G.table. This is why I originally created table.new/table.clear as standalone modules that return a function.

So my question is: with this change, will the type of new_table in the code snippet above still be detected correctly? Ideally I'd like this use-case to not be broken.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the described behavior is what I had in mind. Unfortunately, I don't have the build system set up to try this.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please open a separate issue, I have no time to deal with this recently.

@sumneko
Copy link
Collaborator

sumneko commented May 14, 2022

Thank you!

@sumneko sumneko merged commit cbcbab9 into LuaLS:master May 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants