Type mismatch in function mt:__mul(n)
yaSebastian opened this issue · 1 comments
yaSebastian commented
When looking through the code, Lua Diagnostics states the following type mismatch on the following line of code in function mt:__mul(n)
:
Annotations specify that return value # 1 has a type of
string
, returning value of typenumber
here instead.
number
cannot matchstring
- Type
number
cannot matchstring
return n * self
Also, I'm still quite inexperienced in Lua, so please have my apologies if this is a really stupid question, but in the following code, shouldn't it be impossible for self to be a number
? As far as I understand, __mul(n)
would always be called on a string, unless someone applies either the metatable to another table or the function to another metatable, in which cases you'd have to check against a plethora of other conditions as well.
if type(self) == "number" then
return n * self
end