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

Function assigned to field should be completed as function #1573

Open
carsakiller opened this issue Sep 20, 2022 · 2 comments
Open

Function assigned to field should be completed as function #1573

carsakiller opened this issue Sep 20, 2022 · 2 comments
Labels
enhancement New feature or request

Comments

@carsakiller
Copy link
Collaborator

carsakiller commented Sep 20, 2022

How are you using the lua-language-server?

Visual Studio Code Extension (sumneko.lua)

Which OS are you using?

Windows

What is the issue affecting?

Completion

Expected Behaviour

When providing an alias for a function in a table, the alias should be treated as a function.

Actual Behaviour

When providing an alias for a function in a table, the alias is treated as a field and does not get completed as a function. Hover shows that the field is a function, but completion does not agree or complete with parentheses.

image

Reproduction steps

  1. Use the below code
---@class myTable
local t = {}

---Does a thing
---@param a integer
---@param b string
---@param c boolean
function t.myFunc(a, b, c) end
t.myAlias = t.myFunc
  1. Try to get completions for the function t.myAlias

Additional Notes

This would be incredibly useful for aliasing a function — something that luassert does a lot.

Log File

No response

@carsakiller carsakiller changed the title Field assigned to function should be completed as function Function assigned to field should be completed as function Sep 20, 2022
@carsakiller carsakiller added the bug Something isn't working label Sep 20, 2022
@carsakiller
Copy link
Collaborator Author

Might be related to #1533

@sumneko sumneko added enhancement New feature or request and removed bug Something isn't working labels Nov 23, 2022
@sumneko
Copy link
Collaborator

sumneko commented Nov 23, 2022

Current implementation:

local t = {}

t.f = function () end
t.f = function (x) end
t.f = function (x, y) end

t.f --> Shows 3 items `f()`, `f(x)` and `f(x, y)` here, based on 3 `setfield`

t.g = t.f

t.g --> Only have 1 `setfield`, I can not expand it into 3 items

Need to refactor.

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

No branches or pull requests

2 participants