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
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)
  return rawget(t, n)

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.