Skip to content

Commit

Permalink
issue #198 initialize the _ENV upvalue
Browse files Browse the repository at this point in the history
  • Loading branch information
dibyendumajumdar committed Oct 5, 2020
1 parent 71bb74f commit 523f07b
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/ravi_complib.c
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,14 @@ static int load_and_compile(lua_State* L) {
if (rc == 0) {
lua_assert(cl->nupvalues == cl->p->sizeupvalues);
luaF_initupvals(L, cl);
if (cl->nupvalues >= 1) { /* does it have an upvalue? */
/* get global table from registry */
Table *reg = hvalue(&G(L)->l_registry);
const TValue *gt = luaH_getint(reg, LUA_RIDX_GLOBALS);
/* set global table as 1st upvalue of 'f' (may be LUA_ENV) */
setobj(L, cl->upvals[0]->v, gt);
luaC_upvalbarrier(L, cl->upvals[0], gt);
}
return 1;
}
else {
Expand Down

0 comments on commit 523f07b

Please sign in to comment.