lua-users home
lua-l archive

Re: [ANN] Lua 5.3.4 (rc3) now available

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


> On 27 Jan 2017, at 01:16, nobody <nobody+lua-list@afra-berlin.de> wrote:
> 
> 
> *** lbaselib.c-orig	2017年01月27日 00:33:07.854011135 +0100
> --- lbaselib.c-type2	2017年01月27日 00:32:46.670792561 +0100
> *************** static int luaB_type (lua_State *L) {
> *** 202,207 ****
> --- 202,212 ----
> int t = lua_type(L, 1);
> luaL_argcheck(L, t != LUA_TNONE, 1, "value expected");
> lua_pushstring(L, lua_typename(L, t));
> + int tt = luaL_getmetafield(L, 1, "__name");
> + if (tt == LUA_TSTRING)
> + return 2;
> + if (tt != LUA_TNIL)
> + lua_settop(L, -2);
> return 1;
> }
> 
You’re always getting the `__name` field, shouldn't this only be done if the original type is one that allows for individual meta-tables? eg. not calling it on a `string`, but only on `table` and `userdata` types?
Thijs

AltStyle によって変換されたページ (->オリジナル) /