Calls cannot be tail in the scope of a to-be-closed variable

A to-be-closed variable must be closed when a block ends, so even
a 'return foo()' cannot directly returns the results of 'foo'; the
function must close the scope before returning.
This commit is contained in:
Roberto Ierusalimschy
2018-12-04 15:01:42 -02:00
parent 6d04537ea6
commit 28d829c867
4 changed files with 21 additions and 16 deletions

2
lvm.c
View File

@@ -1565,7 +1565,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) {
if (nparams1) /* vararg function? */
delta = ci->u.l.nextraargs + nparams1;
/* close upvalues from current call */
ProtectNT(luaF_close(L, base, LUA_OK));
luaF_close(L, base, -1); /* (no to-be-closed vars. here) */
updatestack(ci);
}
if (!ttisfunction(s2v(ra))) { /* not a function? */