<HTML><BODY><div>Hello, Sergey!</div><div>Thanks for the review!</div><div> </div><div>Here is the new commit message:</div><div>================================================================================</div><div>test: adapt test checking global environment</div><div><div> </div><div>LuaJIT doesn't take into account tail calls for</div><div>call-level counting, so `getfenv()` behaviour is different</div><div>in tail calls. getfenv()` default level is 1 which is invalid for</div><div>the test case when is called from tail call (`lj_debug_frame()`</div><div>returns NULL).</div><div> </div><div>This commits adds local variables, so there is no tail call any more.</div><div> </div><div>Part of tarantool/tarantool#5870</div><div>Resolves tarantool/tarantool#5713</div><div>================================================================================</div><div> </div><div>And the diff for the comment fix:</div><div>================================================================================</div><div><div><div>diff --git a/test/PUC-Rio-Lua-5.1-tests/closure.lua b/test/PUC-Rio-Lua-5.1-tests/closure.lua</div><div>index 86f6ad87..c4491dcf 100644</div><div>--- a/test/PUC-Rio-Lua-5.1-tests/closure.lua</div><div>+++ b/test/PUC-Rio-Lua-5.1-tests/closure.lua</div><div>@@ -170,9 +170,10 @@ local function foo (a)</div></div><div> </div><div><div> -- LuaJIT doesn't take into account tail calls for</div><div> -- call-level counting, so `getfenv()` behaviour is different</div><div>--- in tail calls. For example, `pcall()` to this functon returns false</div><div>--- in case of tailcall, because `getfenv()` default level is 1 which</div><div>--- is invalid for this case (`lj_debug_frame()` returns NULL).</div><div>+-- in tail calls. For example, `pcall()` to this functon returns</div><div>+-- false in case of tailcall, because `getfenv()` default level</div><div>+-- is 1 which is invalid for this case (`lj_debug_frame()`</div><div>+-- returns NULL).</div><div> -- See also https://github.com/tarantool/tarantool/issues/5713.</div><div>   local env = getfenv()</div><div>   return env</div></div></div><div>================================================================================</div></div><div> </div><div>Best regards,</div><div>Maxim Kokryashkin</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>