From dbb6f11e8ee1eaa496215da5c04af80ec19b4df1 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Mon, 5 Sep 2016 16:06:34 -0300 Subject: [PATCH] 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'.) --- lbaselib.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lbaselib.c b/lbaselib.c index d4c8fef2..98602952 100644 --- a/lbaselib.c +++ b/lbaselib.c @@ -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 */ @@ -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 */