瀏覽代碼

getmetatable doesn't push nil when there is no metatable

Roberto Ierusalimschy 23 年之前
父節點
當前提交
49c95648a0
共有 1 個文件被更改,包括 3 次插入5 次删除
  1. 3 5
      lapi.c

+ 3 - 5
lapi.c

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: lapi.c,v 1.180 2002/03/26 20:46:10 roberto Exp roberto $
+** $Id: lapi.c,v 1.181 2002/03/27 12:49:53 roberto Exp roberto $
 ** Lua API
 ** Lua API
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -416,15 +416,13 @@ LUA_API int lua_getmetatable (lua_State *L, int objindex) {
     default:
     default:
       mt = hvalue(defaultmeta(L));
       mt = hvalue(defaultmeta(L));
   }
   }
-  if (mt == hvalue(defaultmeta(L))) {
-    setnilvalue(L->top);
+  if (mt == hvalue(defaultmeta(L)))
     res = 0;
     res = 0;
-  }
   else {
   else {
     sethvalue(L->top, mt);
     sethvalue(L->top, mt);
+    api_incr_top(L);
     res = 1;
     res = 1;
   }
   }
-  api_incr_top(L);
   lua_unlock(L);
   lua_unlock(L);
   return res;
   return res;
 }
 }