changeset 1566:364859d29ff5

handle nil keys
author Franklin Schmidt <fschmidt@gmail.com>
date Thu, 12 Nov 2020 16:59:47 -0700
parents 44e444a8da64
children 349eef23a13c
files src/luan/LuanTable.java src/luan/impl/LuanImpl.java
diffstat 2 files changed, 4 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
diff -r 44e444a8da64 -r 364859d29ff5 src/luan/LuanTable.java
--- a/src/luan/LuanTable.java	Wed Nov 11 13:17:58 2020 -0700
+++ b/src/luan/LuanTable.java	Thu Nov 12 16:59:47 2020 -0700
@@ -214,6 +214,8 @@
 		if( immutable )
 			throw new LuanException("table is immutable");
 		check();
+		if( key==null )
+			throw new LuanException("table index is nil");
 		Integer iT = Luan.asInteger(key);
 		if( iT != null ) {
 			int i = iT - 1;
diff -r 44e444a8da64 -r 364859d29ff5 src/luan/impl/LuanImpl.java
--- a/src/luan/impl/LuanImpl.java	Wed Nov 11 13:17:58 2020 -0700
+++ b/src/luan/impl/LuanImpl.java	Thu Nov 12 16:59:47 2020 -0700
@@ -236,10 +236,8 @@
 				TableField tblFld = (TableField)fld;
 				Object key = tblFld.key;
 				Object value = tblFld.value;
-				if( key != null && value != null ) {
-					if( table.rawPut(key,value) != null )
-						throw new LuanException("duplicate key in table constructor: "+key);
-				}
+				if( table.rawPut(key,value) != null )
+					throw new LuanException("duplicate key in table constructor: "+key);
 			} else {
 				i++;
 				if( table.rawPut(i,fld) != null )