瀏覽代碼

bug: lua_gettable does not get key from stack top

Roberto Ierusalimschy 25 年之前
父節點
當前提交
c2aa7bd72d
共有 3 個文件被更改,包括 14 次插入3 次删除
  1. 5 0
      bugs
  2. 7 1
      ltests.c
  3. 2 2
      lvm.c

+ 5 - 0
bugs

@@ -208,3 +208,8 @@ Fri Sep 22 15:12:37 EST 2000
 >> `read("*w")' should return nil at EOF
 (by roberto; since 4.0b)
 
+** lvm.c
+Mon Sep 25 11:47:48 EST 2000
+>> lua_gettable does not get key from stack top
+(by Philip Yi; since 4.0b)
+

+ 7 - 1
ltests.c

@@ -1,5 +1,5 @@
 /*
-** $Id: ltests.c,v 1.41 2000/09/11 19:42:57 roberto Exp roberto $
+** $Id: ltests.c,v 1.42 2000/09/14 14:09:31 roberto Exp roberto $
 ** Internal Module for Debugging of the Lua Implementation
 ** See Copyright Notice in lua.h
 */
@@ -410,6 +410,12 @@ static int testC (lua_State *L) {
     else if EQ("insert") {
       lua_insert(L, getnum);
     }
+    else if EQ("gettable") {
+      lua_gettable(L, getnum);
+    }
+    else if EQ("settable") {
+      lua_settable(L, getnum);
+    }
     else if EQ("next") {
       lua_next(L, -2);
     }

+ 2 - 2
lvm.c

@@ -1,5 +1,5 @@
 /*
-** $Id: lvm.c,v 1.135 2000/09/11 17:38:42 roberto Exp roberto $
+** $Id: lvm.c,v 1.136 2000/09/20 17:57:08 roberto Exp roberto $
 ** Lua virtual machine
 ** See Copyright Notice in lua.h
 */
@@ -120,7 +120,7 @@ const TObject *luaV_gettable (lua_State *L, StkId t) {
       ((tg = hvalue(t)->htag) == TAG_TABLE ||  /* with default tag? */
         ttype(luaT_getim(L, tg, IM_GETTABLE)) == TAG_NIL)) { /* or no TM? */
     /* do a primitive get */
-    const TObject *h = luaH_get(L, hvalue(t), t+1);
+    const TObject *h = luaH_get(L, hvalue(t), L->top-1);
     /* result is no nil or there is no `index' tag method? */
     if (ttype(h) != TAG_NIL ||
         (ttype(im=luaT_getim(L, tg, IM_INDEX)) == TAG_NIL))