fix: uncomparable metatables TypeError

This commit is contained in:
Erica Marigold 2024-04-02 23:00:56 +05:30
parent 353ce041ea
commit de25b4d19c
No known key found for this signature in database
GPG key ID: 2768CC0C23D245D1

View file

@ -33,16 +33,14 @@ function Option.new<T>(val: T?)
end, end,
__lt = function<T>(self: Option<T>, other: Option<T>): boolean __lt = function<T>(self: Option<T>, other: Option<T>): boolean
if self:isSome() and other:isSome() then if self:isSome() and other:isSome() then
-- FIXME: TypeError: Type T cannot be compared with < because it has no metatable return (self._optValue :: any) < (other._optValue :: any)
return (self._optValue :: T) < (other._optValue :: T)
end end
return false return false
end, end,
__le = function<T>(self: Option<T>, other: Option<T>): boolean __le = function<T>(self: Option<T>, other: Option<T>): boolean
if self:isSome() and other:isSome() then if self:isSome() and other:isSome() then
-- FIXME: TypeError: Type T cannot be compared with <= because it has no metatable return (self._optValue :: any) <= (other._optValue :: any)
return (self._optValue :: T) <= (other._optValue :: T)
end end
return false return false