diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2016-09-05 16:06:34 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2016-09-05 16:06:34 -0300 |
commit | dbb6f11e8ee1eaa496215da5c04af80ec19b4df1 (patch) | |
tree | ace440b8b0ceb4f6200d69c8c1efe394539b1585 | |
parent | aeb4c6fff1da955ebe9f56385e0683d684f8c60c (diff) | |
download | lua-dbb6f11e8ee1eaa496215da5c04af80ec19b4df1.tar.gz lua-dbb6f11e8ee1eaa496215da5c04af80ec19b4df1.tar.bz2 lua-dbb6f11e8ee1eaa496215da5c04af80ec19b4df1.zip |
bug (with compat on): 'ipairs' can work with any type that provides
an __index; so, 'pairsmeta' should not check for tables. ('pairs'
already checks for tables through 'next'.)
-rw-r--r-- | lbaselib.c | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lbaselib.c,v 1.312 2015/10/29 15:21:04 roberto Exp roberto $ | 2 | ** $Id: lbaselib.c,v 1.313 2016/04/11 19:18:40 roberto Exp roberto $ |
3 | ** Basic library | 3 | ** Basic library |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -208,8 +208,8 @@ static int luaB_type (lua_State *L) { | |||
208 | 208 | ||
209 | static int pairsmeta (lua_State *L, const char *method, int iszero, | 209 | static int pairsmeta (lua_State *L, const char *method, int iszero, |
210 | lua_CFunction iter) { | 210 | lua_CFunction iter) { |
211 | luaL_checkany(L, 1); | ||
211 | if (luaL_getmetafield(L, 1, method) == LUA_TNIL) { /* no metamethod? */ | 212 | if (luaL_getmetafield(L, 1, method) == LUA_TNIL) { /* no metamethod? */ |
212 | luaL_checktype(L, 1, LUA_TTABLE); /* argument must be a table */ | ||
213 | lua_pushcfunction(L, iter); /* will return generator, */ | 213 | lua_pushcfunction(L, iter); /* will return generator, */ |
214 | lua_pushvalue(L, 1); /* state, */ | 214 | lua_pushvalue(L, 1); /* state, */ |
215 | if (iszero) lua_pushinteger(L, 0); /* and initial value */ | 215 | if (iszero) lua_pushinteger(L, 0); /* and initial value */ |