lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


>>>>> "Ranier" == Ranier Vilela <ranier.vf@gmail.com> writes:

 Ranier> There is a bug with pcall().

 Ranier> lbaselib.c:
 Ranier> static int luaB_pcall (lua_State *L) {
 Ranier>   int status;
 Ranier>   luaL_checkany(L, 1);
 Ranier>   lua_pushboolean(L, 1);  /* first result if no errors */
 Ranier>   lua_insert(L, 1);  /* put it in place */
 Ranier>   status = lua_pcallk(L, lua_gettop(L) - 2, LUA_MULTRET, 0, 0, finishpcall);
 Ranier>   return finishpcall(L, status, 0);
 Ranier> }

 Ranier> Should be:
 Ranier> static int luaB_pcall (lua_State *L) {
 Ranier>   int status;
 Ranier>   luaL_checktype(L, 1, LUA_TFUNCTION);

No, because this would generate an error outside the protected
environment. If pcall is called with an invalid function argument it
should raise the error inside the protected call, catch it, and return
it to the caller, not raise the error in the calling context.

-- 
Andrew.