[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: bug: ipairs does not work on userdata if LUA_COMPAT_IPAIRS is enabled
- From: Dirk Laurie <dirk.laurie@...>
- Date: Mon, 18 Jul 2016 14:00:33 +0200
2016-07-18 12:29 GMT+02:00 Tarek Sabet <undefdev@gmail.com>:
> I'm sending this again, because for some reason the last time I sent this it
> ended up unreadable.
It did not; I saw it, but hoped someone else would reply.
> I have found an error that forces the programmer to write backwards
> compatible code if the target is default-compiled Lua 5.3.x.
>
> If LUA_COMPAT_IPAIRS is defined (which it is by default), Lua always ignores
> __index and only checks for __ipairs.
> Therefore ipairs does not work for userdata with an adequate __index field.
It is not a bug.
LUA_COMPAT_IPAIRS means "make ipairs behave as in Lua 5.2". In Lua 5.2,
ipairs does raw access (though the documentation only says so if you read
very carefully), so __index is not consulted.