Shouldn't this be if (!lua_isnil(L, -1)) {
since a module can now return any non-nil Lua value?