lua-users home
lua-l archive

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


Isn't the following a bug ?

> return getmetatable(string).__call
stdin:1: no field '__call' in strings
stack traceback:
        [C]: in function '__index'
        stdin:1: in main chunk
        [C]: in ?

In previous versions of Lua, getmetatable(string) returns nil (which is valid).
Now `string` seems to have a metatable, but which doesn't support
indexing of unknown metamethods.

This is a problem because for testing if a value is callable I used to
write the following:

if type(v) == 'function' or (getmetatable(v) or {}).__call then end

but now this fails for the `string` global table.