From 7d526e75a7f45a2593e874d97c7fdfa0e45cc013 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Mon, 28 Oct 2019 15:58:07 -0300 Subject: Fixed bug in tail calls of __call chains A tail call of a __call chain (a __call metamethod that itself is also not a function) was being perfomed as a regular call. --- lvm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lvm.c') diff --git a/lvm.c b/lvm.c index 5407d144..2c96c58d 100644 --- a/lvm.c +++ b/lvm.c @@ -1549,9 +1549,10 @@ void luaV_execute (lua_State *L, CallInfo *ci) { luaF_close(L, base, NOCLOSINGMETH); lua_assert(base == ci->func + 1); } - if (!ttisfunction(s2v(ra))) { /* not a function? */ + while (!ttisfunction(s2v(ra))) { /* not a function? */ luaD_tryfuncTM(L, ra); /* try '__call' metamethod */ b++; /* there is now one extra argument */ + checkstackp(L, 1, ra); } if (!ttisLclosure(s2v(ra))) { /* C function? */ luaD_call(L, ra, LUA_MULTRET); /* call it */ -- cgit v1.2.3-55-g6feb