[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Strange problem with strict.lua
- From: Dirk Laurie <dirk.laurie@...>
- Date: Fri, 10 May 2013 16:13:11 +0200
2013/5/10 Bernd Eggink <monoped@sudrala.de>:
> 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.
`error` is local, I hope?