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

[Feature Request] Generic Operators #1729

Closed
eigenbom opened this issue Nov 28, 2022 · 2 comments
Closed

[Feature Request] Generic Operators #1729

eigenbom opened this issue Nov 28, 2022 · 2 comments
Labels
bug Something isn't working

Comments

@eigenbom
Copy link

I'd like to be able to define overloads of an operator, for example a matrix class could provide the following overloads of mul:

---@class mat4
---@operator mul(mat4): mat4 -- matrix mult
---@operator mul(vec3): vec3 -- matrix * vector
---@operator mul(number): mat4 -- matrix * constant

However it seems that local y = matrix * vector; is currently deduced as type mat4 | vec3.

Is there a way to achieve this?

@sumneko
Copy link
Collaborator

sumneko commented Nov 29, 2022

image

I cannot reproduce, please provide your sample code.

@sumneko sumneko added the Info Needed More information is required label Nov 29, 2022
@eigenbom
Copy link
Author

image

Thanks for checking that. I found a minimal repro example, seems like this type inheritance with number[] is causing some overload confusion. You can close this ticket and I will remove the number[] type inheritance to work around this.

@sumneko sumneko added bug Something isn't working and removed Info Needed More information is required labels Nov 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants