<HTML><BODY><div>New CI branch: <a href="https://github.com/tarantool/tarantool/tree/fckxorg/gh-5713-adapt-test-global-environment-PUC-Rio-full-ci">https://github.com/tarantool/tarantool/tree/fckxorg/gh-5713-adapt-test-global-environment-PUC-Rio-full-ci</a></div><div> </div><div> </div><blockquote style="border-left:1px solid #0857A6; margin:10px; padding:0 0 0 10px;"><div> <blockquote style="border-left:1px solid #0857A6; margin:10px; padding:0 0 0 10px;"><div id=""><div class="js-helper js-readmsg-msg"><div><div id="style_16396653570272963206_BODY">Hi, Maxim!<br><br>Thanks for the fixes!<br><br>LGTM, except a few nits below.<br><br>On 06.10.21, Maxim Kokryashkin wrote:<br>> LuaJIT doesn't take into account tail calls for<br>> call-level counting, so `getfenv()` behaviour is different<br>> in tail calls. getfenv()` default level is 1 which is invalid for<br>> the test case when is called from tail call (`lj_debug_frame()`<br>> returns NULL).<br>><br>> This commits adds local varibles, so there is no tail call any more.<br><br>Typo: s/varibles/variables/<br><br>><br>> Part of tarantool/tarantool#5870<br><br>It's OK to mention that this patch "Resolves tarantool/tarantool#5713".<br><br>> ---<br>> Issue: <a href="https://github.com/tarantool/tarantool/issues/5713" target="_blank">https://github.com/tarantool/tarantool/issues/5713</a><br>> GitHub branch: <a href="https://github.com/tarantool/luajit/tree/fckxorg/gh-5713-adapt-test-global-environment-PUC-Rio" target="_blank">https://github.com/tarantool/luajit/tree/fckxorg/gh-5713-adapt-test-global-environment-PUC-Rio</a><br>> CI: <a href="https://github.com/tarantool/tarantool/tree/fckxorg/gh-5713-adapt-test-global-environment-PUC-Rio" target="_blank">https://github.com/tarantool/tarantool/tree/fckxorg/gh-5713-adapt-test-global-environment-PUC-Rio</a><br>><br>> test/PUC-Rio-Lua-5.1-tests/closure.lua | 21 +++++++++++----------<br>> 1 file changed, 11 insertions(+), 10 deletions(-)<br>><br>> diff --git a/test/PUC-Rio-Lua-5.1-tests/closure.lua b/test/PUC-Rio-Lua-5.1-tests/closure.lua<br>> index 551fe70d..86f6ad87 100644<br>> --- a/test/PUC-Rio-Lua-5.1-tests/closure.lua<br>> +++ b/test/PUC-Rio-Lua-5.1-tests/closure.lua<br>> @@ -167,22 +167,23 @@ local function foo (a)<br>> assert(getfenv(0) == a)<br>> assert(getfenv(1) == _G)<br>> assert(getfenv(loadstring"") == a)<br>> - return getfenv()<br>> +<br>> +-- LuaJIT doesn't take into account tail calls for<br>> +-- call-level counting, so `getfenv()` behaviour is different<br>> +-- in tail calls. For example, `pcall()` to this functon returns false<br>> +-- in case of tailcall, because `getfenv()` default level is 1 which<br>> +-- is invalid for this case (`lj_debug_frame()` returns NULL).<br>> +-- See also <a href="https://github.com/tarantool/tarantool/issues/5713" target="_blank">https://github.com/tarantool/tarantool/issues/5713</a>.<br><br>Minor: linewidth for comments is 66 symbols.<br><br>> + local env = getfenv()<br>> + return env<br>> end<br>><br>> f = coroutine.wrap(foo)<br>> local a = {}<br>> assert(f(a) == _G)<br>> local a,b = pcall(f)<br>> --- FIXME: LuaJIT doesn't take into account tail calls for<br>> --- call-level counting, so `getfenv()` behaviour is different<br>> --- in tail calls. For example, this `pcall()` returns false,<br>> --- because `getfenv()` default level is 1 which is invalid for<br>> --- this case when is called from tail call (`lj_debug_frame()`<br>> --- returns NULL).<br>> --- See also <a href="https://github.com/tarantool/tarantool/issues/5713" target="_blank">https://github.com/tarantool/tarantool/issues/5713</a>.<br>> --- Test is disabled for LuaJIT for now.<br>> --- assert(a and b == _G)<br>> +-- Test is adapted to the behavior LuaJIT. See the comment above.<br>> +assert(a and b == _G)<br>><br>><br>> -- tests for multiple yield/resume arguments<br>> --<br>> 2.33.0<br>><br><br>--<br>Best regards,<br>Sergey Kaplun</div></div></div></div></blockquote><div> </div></div></blockquote></BODY></HTML>