[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: 5.2 refman misstates stack signature of luaL_len?
- From: Dubiousjim <lists+lua@...>
- Date: Tue, 29 May 2012 09:02:01 -0400
On Mon, May 28, 2012 at 08:22:54PM -0300, Roberto Ierusalimschy wrote:
> > Lua 5.2.1 (rc2) is now available at
> > http://www.lua.org/work/lua-5.2.1-rc2.tar.gz
Since this doesn't seem to have been caught yet, I'll point it out
again:
On Fri, May 18, 2012 at 03:07:58PM -0400, Dubiousjim wrote:
> The 5.2 reference manual states the stack behavior of luaL_len as [-0, +1, e].
>
> But judging by lauxlib.c, it looks like it's instead [-0, +0, e].
>
> LUALIB_API int luaL_len (lua_State *L, int idx) {
> int l;
> int isnum;
> lua_len(L, idx); /* <---- this pushes an object to stack */
> l = (int)lua_tointegerx(L, -1, &isnum);
> if (!isnum)
> luaL_error(L, "object length is not a number");
> lua_pop(L, 1); /* remove object <----- but notice */
> return l;
> }
--
Jim Pryor
dubiousjim@gmail.com