On Thu, May 10, 2012 at 12:03 PM, Mike Pall <mike-1205@xxxxxxxxxx> wrote: > Ignacio Burgueño wrote: > > On a similar note, that same code on Win x64 gives an error message may > be > > a bit misleading. > > > > LuaJIT 2.0.0-beta10 -- Copyright (C) 2005-2012 Mike Pall. > http://luajit.org/ > > JIT: ON CMOV SSE2 SSE3 SSE4.1 fold cse dce fwd dse narrow loop abc fuse > > > > stdin:1: attempt to call global 'tostring' (a string value) > > stack traceback: > > stdin:1: in main chunk > > [C]: ? > > Well, yes. That's a consequence of tostring() tail-calling the > __tostring metamethod (i.e. the string value). The variable name > derived by the error handler points to tostring as the culprit. In > general, you may get strange errors when tail calls come into play. Ah, I see. Thanks for the clarification. It seems that not only tail calls but metamethods may give strange errors. I wasn't aware of the following in plain Lua: > t = setmetatable({}, { __add = "not a function" }) > print(type(t)) table > print(t + 1) attempt to call a string value stack traceback: stdin:1: in main chunk [C]: ? Regards, Ignacio