<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">Index: lvm.c
===================================================================
--- lvm.c	(revision 1813)
+++ lvm.c	(working copy)
@@ -189,11 +189,9 @@
 static int call_orderTM (lua_State *L, const TValue *p1, const TValue *p2,
                          TMS event) {
   const TValue *tm1 = luaT_gettmbyobj(L, p1, event);
-  const TValue *tm2;
-  if (ttisnil(tm1)) return -1;  /* no metamethod? */
-  tm2 = luaT_gettmbyobj(L, p2, event);
-  if (!luaO_rawequalObj(tm1, tm2))  /* different metamethods? */
-    return -1;
+  if (ttisnil(tm1))
+    tm1 = luaT_gettmbyobj(L, p2, event);  /* try second operand */
+  if (!ttisfunction(tm1)) return 0;
   callTMres(L, L-&gt;top, tm1, p1, p2);
   return !l_isfalse(L-&gt;top);
 }
@@ -223,13 +221,13 @@
 
 int luaV_lessthan (lua_State *L, const TValue *l, const TValue *r) {
   int res;
-  if (ttype(l) != ttype(r))
-    return luaG_ordererror(L, l, r);
-  else if (ttisnumber(l))
-    return luai_numlt(L, nvalue(l), nvalue(r));
-  else if (ttisstring(l))
-    return l_strcmp(rawtsvalue(l), rawtsvalue(r)) &lt; 0;
-  else if ((res = call_orderTM(L, l, r, TM_LT)) != -1)
+  if (ttype(l) == ttype(r)) {
+    if (ttisnumber(l))
+      return luai_numlt(L, nvalue(l), nvalue(r));
+    else if (ttisstring(l))
+      return l_strcmp(rawtsvalue(l), rawtsvalue(r)) &lt; 0;
+  }
+  if ((res = call_orderTM(L, l, r, TM_LT)) != -1)
     return res;
   return luaG_ordererror(L, l, r);
 }
@@ -237,13 +235,13 @@
 
 static int lessequal (lua_State *L, const TValue *l, const TValue *r) {
   int res;
-  if (ttype(l) != ttype(r))
-    return luaG_ordererror(L, l, r);
-  else if (ttisnumber(l))
-    return luai_numle(L, nvalue(l), nvalue(r));
-  else if (ttisstring(l))
-    return l_strcmp(rawtsvalue(l), rawtsvalue(r)) &lt;= 0;
-  else if ((res = call_orderTM(L, l, r, TM_LE)) != -1)  /* first try `le' */
+  if (ttype(l) == ttype(r)) {
+    if (ttisnumber(l))
+      return luai_numle(L, nvalue(l), nvalue(r));
+    else if (ttisstring(l))
+      return l_strcmp(rawtsvalue(l), rawtsvalue(r)) &lt;= 0;
+  }
+  if ((res = call_orderTM(L, l, r, TM_LE)) != -1) /* first try `le' */
     return res;
   else if ((res = call_orderTM(L, r, l, TM_LT)) != -1)  /* else try `lt' */
     return !res;
@@ -253,7 +251,9 @@
 
 int luaV_equalval (lua_State *L, const TValue *t1, const TValue *t2) {
   const TValue *tm;
-  lua_assert(ttype(t1) == ttype(t2));
+  if (ttype(t1) != ttype(t2))
+	  return call_orderTM(L, t1, t2, TM_EQ) &gt; 0;
+
   switch (ttype(t1)) {
     case LUA_TNIL: return 1;
     case LUA_TNUMBER: return luai_numeq(L, nvalue(t1), nvalue(t2));
Index: lvm.h
===================================================================
--- lvm.h	(revision 1813)
+++ lvm.h	(working copy)
@@ -18,10 +18,8 @@
 #define tonumber(o,n)	(ttype(o) == LUA_TNUMBER || \
                          (((o) = luaV_tonumber(o,n)) != NULL))
 
-#define equalobj(L,o1,o2) \
-	(ttype(o1) == ttype(o2) &amp;&amp; luaV_equalval(L, o1, o2))
+#define equalobj(L,o1,o2) luaV_equalval(L, o1, o2)
 
-
 LUAI_FUNC int luaV_lessthan (lua_State *L, const TValue *l, const TValue *r);
 LUAI_FUNC int luaV_equalval (lua_State *L, const TValue *t1, const TValue *t2);
 LUAI_FUNC const TValue *luaV_tonumber (const TValue *obj, TValue *n);
</pre></body></html>