more relaxed rules for __eq metamethod (more similar to other

operators)
This commit is contained in:
Roberto Ierusalimschy
2014-06-10 15:53:18 -03:00
parent 542b6cfc02
commit 1a3656e56e
3 changed files with 11 additions and 20 deletions

15
ltm.c
View File

@@ -1,5 +1,5 @@
/*
** $Id: ltm.c,v 2.25 2013/12/30 20:47:58 roberto Exp $
** $Id: ltm.c,v 2.26 2014/04/11 20:17:39 roberto Exp roberto $
** Tag methods
** See Copyright Notice in lua.h
*/
@@ -129,19 +129,6 @@ void luaT_trybinTM (lua_State *L, const TValue *p1, const TValue *p2,
}
const TValue *luaT_getequalTM (lua_State *L, Table *mt1, Table *mt2) {
const TValue *tm1 = fasttm(L, mt1, TM_EQ);
const TValue *tm2;
if (tm1 == NULL) return NULL; /* no metamethod */
if (mt1 == mt2) return tm1; /* same metatables => same metamethods */
tm2 = fasttm(L, mt2, TM_EQ);
if (tm2 == NULL) return NULL; /* no metamethod */
if (luaV_rawequalobj(tm1, tm2)) /* same metamethods? */
return tm1;
return NULL;
}
int luaT_callorderTM (lua_State *L, const TValue *p1, const TValue *p2,
TMS event) {
if (!luaT_callbinTM(L, p1, p2, L->top, event))