From dba17070ac2a6a54079b0b935635377545a3b764 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy <roberto@inf.puc-rio.br> Date: Thu, 17 Jun 2004 11:06:52 -0300 Subject: optional error for accesss to undefined variables/fields --- lauxlib.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'lauxlib.c') diff --git a/lauxlib.c b/lauxlib.c index 765065c5..e1890780 100644 --- a/lauxlib.c +++ b/lauxlib.c @@ -1,5 +1,5 @@ /* -** $Id: lauxlib.c,v 1.114 2004/06/02 13:50:46 roberto Exp roberto $ +** $Id: lauxlib.c,v 1.115 2004/06/02 19:06:14 roberto Exp roberto $ ** Auxiliary functions for building Lua libraries ** See Copyright Notice in lua.h */ @@ -243,6 +243,8 @@ LUALIB_API void luaL_openlib (lua_State *L, const char *libname, if (lua_isnil(L, -1)) { /* no? */ lua_pop(L, 1); lua_newtable(L); /* create it */ + if (lua_getmetatable(L, LUA_GLOBALSINDEX)) + lua_setmetatable(L, -2); /* share metatable with global table */ lua_pushvalue(L, -1); /* register it with given name */ lua_setglobal(L, libname); -- cgit v1.2.3-55-g6feb