Skip to content

Commit

Permalink
bug (with compat on): 'ipairs' can work with any type that provides
Browse files Browse the repository at this point in the history
an __index; so, 'pairsmeta' should not check for tables. ('pairs'
already checks for tables through 'next'.)
  • Loading branch information
roberto-ieru committed Sep 5, 2016
1 parent aeb4c6f commit dbb6f11
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lbaselib.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
** $Id: lbaselib.c,v 1.312 2015/10/29 15:21:04 roberto Exp roberto $
** $Id: lbaselib.c,v 1.313 2016/04/11 19:18:40 roberto Exp roberto $
** Basic library
** See Copyright Notice in lua.h
*/
Expand Down Expand Up @@ -208,8 +208,8 @@ static int luaB_type (lua_State *L) {

static int pairsmeta (lua_State *L, const char *method, int iszero,
lua_CFunction iter) {
luaL_checkany(L, 1);
if (luaL_getmetafield(L, 1, method) == LUA_TNIL) { /* no metamethod? */
luaL_checktype(L, 1, LUA_TTABLE); /* argument must be a table */
lua_pushcfunction(L, iter); /* will return generator, */
lua_pushvalue(L, 1); /* state, */
if (iszero) lua_pushinteger(L, 0); /* and initial value */
Expand Down

0 comments on commit dbb6f11

Please sign in to comment.