Fix table.unpack.

This commit is contained in:
Enyby
2019-11-02 15:18:48 +02:00
parent 05e82f1c3f
commit b57eb247ba

View File

@@ -140,11 +140,9 @@ public class TableLib extends TwoArgFunction {
static class unpack extends VarArgFunction {
public Varargs invoke(Varargs args) {
LuaTable t = args.checktable(1);
switch (args.narg()) {
case 1: return t.unpack();
case 2: return t.unpack(args.checkint(2));
default: return t.unpack(args.checkint(2), args.checkint(3));
}
// do not waste resource for calc rawlen if arg3 is not nil
int len = args.arg(3).isnil() ? t.rawlen() : 0;
return t.unpack(args.optint(2, 1), args.optint(3, len));
}
}
}