# HG changeset patch # User Kim Alvefur # Date 1579119510 -3600 # Node ID 13d5fb74648f86d04636bac57d9c898f9d5fa665 # Parent 079b31c8dbf2a7225b0f51092412ab0dd1947257 util.set: Fix equality metamethod in Lua 5.3 diff -r 079b31c8dbf2 -r 13d5fb74648f util/set.lua --- a/util/set.lua Wed Jan 15 21:16:08 2020 +0100 +++ b/util/set.lua Wed Jan 15 21:18:30 2020 +0100 @@ -8,6 +8,7 @@ local ipairs, pairs, setmetatable, next, tostring = ipairs, pairs, setmetatable, next, tostring; +local getmetatable = getmetatable; local t_concat = table.concat; local _ENV = nil; @@ -146,6 +147,11 @@ return new_set; end function set_mt.__eq(set1, set2) + if getmetatable(set1) ~= set_mt or getmetatable(set2) ~= set_mt then + -- Lua 5.3+ calls this if both operands are tables, even if metatables differ + return false; + end + set1, set2 = set1._items, set2._items; for item in pairs(set1) do if not set2[item] then