for _, v in pairs(argtypes) do
local fstring = fstring .. string.format(", %s", v)
end
should be:
for _, v in pairs(argtypes) do
fstring = fstring .. string.format(", %s", v)
end
Otherwise the argument list will always be a local variable and never actually contain any function types.