With the intention of announcing a positive result, I just tried
Knuth's "man or boy" test from ye olde Algol days with
Lua, but my test program doesn't return the correct -67
but rather -299.
The statement "function B() ... end" is writing to the global variable B each time. Try "local function B() ... end" instead.