[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: `require()` semantics?
- From: Philipp Janda <siffiejoe@...>
- Date: Wed, 25 Jun 2014 05:57:24 +0200
Am 25.06.2014 02:59 schröbte Pierre-Yves Gérardy:
I think I've found a bug in the C loader/seracher of Lua 5.1:
With the current version of require51 found at
if the sentinel is a table, it ends up being populated by the C loader
as if it were the module.
The sentinel is not a table but a lightuserdata, so maybe the bug is in
the current version of `require51` ...
E.g. both `luaL_register` and the `module` function assume that the
sentinel is _not_ a table (the C searcher has nothing to do with it,
neither does the C loader unless it calls `luaL_register` with a
non-NULL library name). Even with a non-table sentinel, `require51`
doesn't work correctly with a module that uses `module` or
`luaL_register` and doesn't return a value.
Also, the searcher can be any callable object, but the loader has to be
For eample, requiring lpeg twice triggers the cycle detection code. If
the sentinel has another type, the error does not occur.
However it is nowhere passed as a parameter to anything... I suppose
it is left on the stack and coopted by the loader.