I think this is because of the introduction of to-be-closed variables
in Lua 5.4 and the fourth argument to generic for-loops. Note, however,
that the example program does not use to-be-closed variables. Yet, the
generic for-loop prohibits the recursive call to be executed as a tail
call.
It'll be tricky to fix this because it is not known until runtime whether a function like 'pairs' returns a to-be-closed variable.
Closing the to-be-closed variable before the return may make the loop variables inaccessible, introducing another problem.