Skip to content

Commit

Permalink
Fix mistake in Type.__eq
Browse files Browse the repository at this point in the history
  • Loading branch information
edubart committed Sep 29, 2020
1 parent bd9c024 commit a2e23c6
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions nelua/types.lua
Original file line number Diff line number Diff line change
Expand Up @@ -359,14 +359,15 @@ function Type:__tostring()
end

-- Compare if two types are equal.
function Type:__eq(t)
if type(t) == 'table' and t._type then -- t is a type
if self.id == t.id then -- early check for same type (optimization)
function Type.__eq(t1, t2)
if type(t1) == 'table' and t1._type then -- t1 is a type
if t1.id == t2.id then -- early check for same type (optimization)
-- types with the same type id should always be the same
return true
end
return self:is_equal(t)
return t1:is_equal(t2)
end
return false
end

Type.unary_operators['not'] = function(_, attr)
Expand Down

0 comments on commit a2e23c6

Please sign in to comment.