Skip to content

Commit f9c6d3d

Browse files
committed
fix: < > <= >= on aliases to comparable types return boolean
Fixes #844.
1 parent be8ac11 commit f9c6d3d

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

spec/lang/operator/lt_spec.lua

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,12 @@ describe("<", function()
3030
]], {
3131
{ msg = "cannot use operator '<' for types boolean and integer" }
3232
}))
33+
34+
it("< on aliases to comparable types return boolean", util.check([[
35+
local type Test = integer
36+
37+
local function f(a: Test, b: Test) : boolean
38+
return a < b
39+
end
40+
]]))
3341
end)

tl.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12623,7 +12623,7 @@ self:expand_type(node, values, elements) })
1262312623
end
1262412624
end
1262512625

12626-
if ua.typename == "nominal" and ub.typename == "nominal" and not meta_on_operator then
12626+
if (not t) and ua.typename == "nominal" and ub.typename == "nominal" and not meta_on_operator then
1262712627
if self:is_a(ua, ub) then
1262812628
t = ua
1262912629
else

tl.tl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12623,7 +12623,7 @@ do
1262312623
end
1262412624
end
1262512625

12626-
if ua is NominalType and ub is NominalType and not meta_on_operator then
12626+
if (not t) and ua is NominalType and ub is NominalType and not meta_on_operator then
1262712627
if self:is_a(ua, ub) then
1262812628
t = ua
1262912629
else

0 commit comments

Comments
 (0)