The number of Lua 5.1 compat hacks is increasing.
Supporting 3-4 different Lua versions isn't going to be sustainable.
List of issues (add more in comments):
* _G.unpack vs table.unpack (see everywhere)
* xpcall takes no arguments for the function (reason for util.compat/.xpcall)
* math.log missing the 'base' argument (see util.human.units)
* __len meta-method does not work on tables (see #1598)
* Missing luaL_buffinitsize (see https://hg.prosody.im/trunk/rev/712b2e6a09d9 )