lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


> I am looking at the reference manual for Lua 5.3, specifically the C
> API function luaL_testudata. It appears this function can somehow raise
> errors, as it is marked [-0, +0, e], but looking at the implementation
> of this function within the source code, I don't see how. It doesn't
> appear to raise anything by itself, and all of the functions it calls
> are marked as not raising errors.
> 
> - lua_touserdata [-0, +0, –]
> - lua_getmetatable [-0, +(0|1), –]
> - luaL_getmetatable [-0, +1, –]
> - lua_rawequal [-0, +0, –]
> - lua_pop [-n, +0, –]
> 
> Is this an error in the documentation, or am I missing something?

There is an error, but it is in luaL_getmetatable. luaL_getmetatable is
a macro over lua_getfield, which can raise a memory error (because
it may need to internalize the field name).

(In fact, both luaL_getmetatable and luaL_testudata cannot raise errors
if the type name exists and it is not too long, because in that case the
string with that name is already present in Lua. But that is based on
"implementation details".)

Thanks for the feedback.

-- Roberto