lua-language-server
lua-language-server copied to clipboard
overloading function makes returns inaccurate
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:
Creating a function overload by defining it more than once seems to override the returns always although:
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.
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.
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:
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:
The issue looks like it is the same as #871.
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.
Only select overload by number of parameters for now.