lua-users home
lua-l archive

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

On 10.05.2013 16:13, Dirk Laurie wrote:
2013/5/10 Bernd Eggink <>:
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.

`error` is local, I hope?

Well, to make sure I inserted
	local error = error
at the top of the module, which didn't help, and I also said:
	mt.__declared = { error }
so that "error" is considered declared, but that didn't help either.