lua-language-server icon indicating copy to clipboard operation
lua-language-server copied to clipboard

overloading function makes returns inaccurate

Open Bilal2453 opened this issue 2 years ago • 3 comments

When setting an overload for some function with different returns, the suggested returns are always the sum of all possible returns no matter the used overload used.

For example: image

Creating a function overload by defining it more than once seems to override the returns always although:

image

Not entirely sure if this is indeed the expected behavior, but it definitely seems like the language server has enough context to figure out the return type easily enough, I would suppose.

Bilal2453 avatar May 16 '22 12:05 Bilal2453

I believe with your second version would actually function differently. In this case you are redefining the x function the second time. Yes this is totally fine in Lua. So I believe that's why it's doing this. As for the first, I'm not sure. I'd love to enable that feature also.

hahn-kev avatar May 20 '22 00:05 hahn-kev

For the second one, I don't think it is actually overriding the definitions no. It seems that it actually properly overload the function definitions. Here this example:

image

The only case it seems to override them is if they were a local function (or more accurately, the function was not defined in a table). In which case it makes sense to override that definition to the last defined function:

image

Bilal2453 avatar May 20 '22 14:05 Bilal2453

The issue looks like it is the same as #871.

C3pa avatar May 28 '22 19:05 C3pa

Just remembered this issue exists. Testing again on 3.6.11 and the same behavior as described initially, have not changed. Doesn't seem related to #871.

Bilal2453 avatar Apr 12 '23 09:04 Bilal2453

Only select overload by number of parameters for now.

sumneko avatar Apr 24 '23 07:04 sumneko