# HG changeset patch # User Kim Alvefur # Date 1579119368 -3600 # Node ID 079b31c8dbf2a7225b0f51092412ab0dd1947257 # Parent 9918b4b0cd588b8121e57fe5e9a0b1c1bf5937bc util.ip: Fix equality metamethod for Lua 5.3 diff -r 9918b4b0cd58 -r 079b31c8dbf2 util/ip.lua --- a/util/ip.lua Wed Jan 15 21:08:01 2020 +0100 +++ b/util/ip.lua Wed Jan 15 21:16:08 2020 +0100 @@ -19,8 +19,14 @@ return ret; end, __tostring = function (ip) return ip.addr; end, - __eq = function (ipA, ipB) return ipA.packed == ipB.packed; end }; +ip_mt.__eq = function (ipA, ipB) + if getmetatable(ipA) ~= ip_mt or getmetatable(ipB) ~= ip_mt then + -- Lua 5.3+ calls this if both operands are tables, even if metatables differ + return false; + end + return ipA.packed == ipB.packed; +end local hex2bits = { ["0"] = "0000", ["1"] = "0001", ["2"] = "0010", ["3"] = "0011",