lua-users home
lua-l archive

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


In the lua manual [http://www.lua.org/manual/5.1/manual.html#2.8], it makes it look like the __unm metamethod is called with one argument, the operand. But it actually appears to be calling the __unm method with two arguments, the second being a duplicate of the first argument. I'd say that this is fairly trivial and doesn't effect much of anything, but it still is a slight discrepency that could easily be fixed. 

I noticed it while adjusting the stack top ( with lua_settop ) in a C __unm metamethod, but that is probably one of the only situations that it would affect. Also the 5.2.0-work4 manual also has this same error.

Here is a lua snippet that demonstrates what I'm talking about:

local test = setmetatable({}, { __unm = function(...)
	assert(select("#", ...) == 2)
	assert(select(1, ...) == select(2, ...))
end })
local _ = -test


Peter