Skip to content

overloading function makes returns inaccurate #1146

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
Bilal2453 opened this issue May 16, 2022 · 7 comments
Closed

overloading function makes returns inaccurate #1146

Bilal2453 opened this issue May 16, 2022 · 7 comments
Labels
enhancement New feature or request

Comments

@Bilal2453
Copy link
Contributor

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 Bilal2453 changed the title overloads report invalid returns overloading function makes returns inaccurate May 16, 2022
@hahn-kev
Copy link
Contributor

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.

@Bilal2453
Copy link
Contributor Author

Bilal2453 commented May 20, 2022

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

@sumneko sumneko added the enhancement New feature or request label May 24, 2022
@C3pa
Copy link
Contributor

C3pa commented May 28, 2022

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

@Bilal2453
Copy link
Contributor Author

Bilal2453 commented Apr 12, 2023

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.

@sumneko
Copy link
Collaborator

sumneko commented Apr 24, 2023

Only select overload by number of parameters for now.

@Bilal2453
Copy link
Contributor Author

This seems to be fixed now with #2822

Thanks @tomlau10!

@tomlau10
Copy link
Contributor

tomlau10 commented Nov 4, 2024

This seems to be fixed now with #2822

This is not fixed by my #2822 🤔
When I was working on that PR, I found that this issue have already been fixed as of v3.10.5.

Anyway glad that it is fixed 😄

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

No branches or pull requests

5 participants