lua-users home
lua-l archive

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


On 24 December 2014 at 14:40, Steven Degutis <sbdegutis@gmail.com> wrote:
> The documentation doesn't seem to explain the __name metatable field
> in the same place as the other valid metatable fields.

The new respect for the __name metafield by argument checking is
actually a bigger change I didn't even know about until you mentioned
it on IRC today.
The feature can bring about some potentially confusing error messages.
As discovered by xyzzy__:

> math.sin(setmetatable({},{__name = 'number'}))
sandbox:1: bad argument #1 to 'sin' (number expected, got number)
stack traceback:
 [C]: in function 'math.sin'
sandbox:1: in main chunk

Could this be changed to something like:
"bad argument #%d to '%s' (%s (%s) expected, got %s (%s))"
where each first %s is the base type (as returned by lua_typename),
and the %s in parenthesis is the __name metafield?