diff --git a/src/if_lua.c b/src/if_lua.c
index 9852c61..21141d8 100644
--- a/src/if_lua.c
+++ b/src/if_lua.c
@@ -457,7 +457,7 @@ lua_enabled(int verbose)
}
#endif
-#if LUA_VERSION_NUM > 501
+#if LUA_VERSION_NUM > 501 && LUA_VERSION_NUM < 504
static int
luaL_typeerror(lua_State *L, int narg, const char *tname)
{