lua-users home
lua-l archive

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


Hi all,

I've just been struggling with a bug that caused my program to go into an infinite loop at a certain point for no obvious reason. As I'm in the habit of starting each source with "require strict", I didn't expect it to be something as simple as the usage of an undefined (and undeclared) global. I use the module from
http://metalua.luaforge.net/src/lib/strict.lua.html
It happens in the __index metafunction, which is defined like this:

mt.__index = function (t, n)
  if not mt.__declared[n] and debug.getinfo(2, "S").what ~= "C" then
     error("variable '"..n.."' is not declared", 2)
  end
  return rawget(t, n)
end

The baffling fact is that the function 'error' from the standard library loops and eats up 100% CPU, instead of aborting the program. If the line is replaced by os.exit(1), the program halts immediately.

Any ideas what may have caused such behaviour? I checked if the value of error had been changed, but it hasn't.

Regards,
Bernd

--
http://sudrala.de