Replies: 2 comments 1 reply
-
|
What is the reason for that? Builtin |
Beta Was this translation helpful? Give feedback.
1 reply
-
|
You have to annotate metamethods separately for each type, which mimics Lua's metatable behavior. (Translated by ChatGPT) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hypothetically, say we have this function:
The naive case the annotation would be
However the metamethod
__addalso exists, which gives support to+operator.Hence more accurate annotation would be
Now this annotation is not fully correct neither (but tbh good enough for me).
In fully correct annotation only param
aneeds the metamethod implemented, parambneeds to be valid input toa.__add(via---@operator add(...):...and the return value should be the return value of said operator annotation.Is it possible to limit the annotation to anything with an implemented metamethod?
Beta Was this translation helpful? Give feedback.
All reactions