Diff

util/set.lua @ 11120:b2331f3dfeea

Merge 0.11->trunk
author Matthew Wild <mwild1@gmail.com>
date Wed, 30 Sep 2020 09:50:33 +0100
parent 10594:13d5fb74648f
child 11560:3bbb1af92514
line wrap: on
line diff
--- a/util/set.lua	Thu Oct 01 15:08:58 2020 +0100
+++ b/util/set.lua	Wed Sep 30 09:50:33 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