lua-users home
lua-l archive

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


On Dec 25, 2014 7:59 AM, "Luiz Henrique de Figueiredo" <lhf@tecgraf.puc-rio.br> wrote:
>
> > > math.sin(setmetatable({},{__name = 'number'}))
> > sandbox:1: bad argument #1 to 'sin' (number expected, got number)
>
> So, don't use the name of a basic type as the name of your type...
>
> > 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?
>
> And then get this?
>         bad argument #1 to 'sin' (number (number) expected, got number (number))
>

I agree. The way it is now is perfect as long as you don't go naming things after existing types.