lua-users home
lua-l archive

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


Hello All,
I was testing the unary minus code, I am working on and found an error.
According to lua manual for lua 5.1.X, the handler looks like:
-- Try to get a handler from the operand
local h = metatable(op).__unm
if h then
  -- call the handler with the operand
  return h(op)
else  -- no handler available: default behavior
  error(···)
end

However when I run this test program: 

function printargs(...) table.foreach({...},print) end
clss={}
mt={__unm=printargs}
setmetatable(clss,mt)
a=-clss

It reports that there are in fact two arguments (the table repeated twice).

This occurs on lua 5.1, 5.1.1 & 5.1.2 compiled using mingw in windows.

Is the manual wrong, or is there a bug in the code?

Regards,
Mark