JakobOvrum/LuaD

nil doesn't seem to work properly.

Opened this issue · 2 comments

LuaObject initialises to L=null, r = LUA_REFNIL. Then there's code:

@property bool isNil() pure nothrow @safe
	{
		return r == LUA_REFNIL;
	}

It looks like a nil object is treated as a lua nil... which makes sense to me... but then you try and copy it:

LuaObject x = LuaObject();
LuaObject y = x;

Crash, because L == null, and the function tries to push the value. Should there be a check in the postblit that inhibits this behaviour if the object is nil?

Should there be a check in the postblit that inhibits this behaviour if the object is nil?

Yeah, that sounds right. I wonder if there are other behaviours on nil that should be supported.

This problem is everywhere... it'll be a big effort to smooth this over, otherwise I would have submit a patch ;)