BaseLib: fix handling of __tostring

This commit is contained in:
gamax92
2019-08-11 12:05:48 +02:00
committed by asie
parent 2bccb4670e
commit 626664a0fe

View File

@@ -350,8 +350,11 @@ public class BaseLib extends TwoArgFunction implements ResourceFinder {
static final class tostring extends LibFunction {
public LuaValue call(LuaValue arg) {
LuaValue h = arg.metatag(TOSTRING);
if ( ! h.isnil() )
return h.call(arg);
if ( ! h.isnil() ) {
LuaValue v = h.call(arg);
LuaValue vs = v.tostring();
return !vs.isnil() ? vs : v;
}
LuaValue v = arg.tostring();
if ( ! v.isnil() )
return v;