changeset 1706:93b9fd13a06c

Luan.arg fix
author Franklin Schmidt <fschmidt@gmail.com>
date Mon, 04 Jul 2022 12:30:16 -0600
parents a6e27c8e7ef4
children ad5647031343
files src/luan/LuanTable.java src/luan/modules/Luan.luan
diffstat 2 files changed, 8 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/luan/LuanTable.java	Sun Jul 03 21:59:38 2022 -0600
+++ b/src/luan/LuanTable.java	Mon Jul 04 12:30:16 2022 -0600
@@ -259,7 +259,11 @@
 
 	public Object removeFromList(int pos) throws LuanException {
 		checkMutable();
-		return list().remove(pos-1);
+		try {
+			return list().remove(pos-1);
+		} catch(IndexOutOfBoundsException e) {
+			throw new LuanException("index out of bounds - "+e.getMessage());
+		}
 	}
 
 	public void rawSort(Comparator<Object> cmp) throws LuanException {
--- a/src/luan/modules/Luan.luan	Sun Jul 03 21:59:38 2022 -0600
+++ b/src/luan/modules/Luan.luan	Mon Jul 04 12:30:16 2022 -0600
@@ -51,7 +51,9 @@
 
 if JavaLuan.args ~= nil then
 	local args = TableLuan.toTable(JavaLuan.args)
-	args[0] = TableLuan.remove(args,1)
+	if #args > 0 then
+		args[0] = TableLuan.remove(args,1)
+	end
 	Luan.arg = args
 end