Skip to content

Commit

Permalink
fix: < > <= >= on aliases to comparable types return boolean
Browse files Browse the repository at this point in the history
  • Loading branch information
hishamhm committed Nov 16, 2024
1 parent be8ac11 commit f9c6d3d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
8 changes: 8 additions & 0 deletions spec/lang/operator/lt_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,12 @@ describe("<", function()
]], {
{ msg = "cannot use operator '<' for types boolean and integer" }
}))

it("< on aliases to comparable types return boolean", util.check([[
local type Test = integer
local function f(a: Test, b: Test) : boolean
return a < b
end
]]))
end)
2 changes: 1 addition & 1 deletion tl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12623,7 +12623,7 @@ self:expand_type(node, values, elements) })
end
end

if ua.typename == "nominal" and ub.typename == "nominal" and not meta_on_operator then
if (not t) and ua.typename == "nominal" and ub.typename == "nominal" and not meta_on_operator then
if self:is_a(ua, ub) then
t = ua
else
Expand Down
2 changes: 1 addition & 1 deletion tl.tl
Original file line number Diff line number Diff line change
Expand Up @@ -12623,7 +12623,7 @@ do
end
end

if ua is NominalType and ub is NominalType and not meta_on_operator then
if (not t) and ua is NominalType and ub is NominalType and not meta_on_operator then
if self:is_a(ua, ub) then
t = ua
else
Expand Down

0 comments on commit f9c6d3d

Please sign in to comment.