changeset 1821:d28f5ed56454

fix stringify empty list
author Franklin Schmidt <fschmidt@gmail.com>
date Tue, 09 Jul 2024 07:17:41 -0600
parents f3ec7f053078
children aeaf2b65c005
files src/luan/LuanTable.java src/luan/modules/parsers/LuanToString.java
diffstat 2 files changed, 7 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
diff -r f3ec7f053078 -r d28f5ed56454 src/luan/LuanTable.java
--- a/src/luan/LuanTable.java	Sun Jun 30 20:54:36 2024 -0600
+++ b/src/luan/LuanTable.java	Tue Jul 09 07:17:41 2024 -0600
@@ -94,6 +94,10 @@
 		return map==null || map.isEmpty();
 	}
 
+	public boolean isOnlyList() {
+		return isList() && list!=null;
+	}
+
 	public boolean isMap() {
 		return map!=null || list==null;
 	}
diff -r f3ec7f053078 -r d28f5ed56454 src/luan/modules/parsers/LuanToString.java
--- a/src/luan/modules/parsers/LuanToString.java	Sun Jun 30 20:54:36 2024 -0600
+++ b/src/luan/modules/parsers/LuanToString.java	Tue Jul 09 07:17:41 2024 -0600
@@ -234,13 +234,15 @@
 			}
 			toString(entry,sb,indented+1,settings);
 		}
-		if( !list.isEmpty() || !map.isEmpty() ) {
+		if( !tbl.isEmpty() ) {
 			if( settings.compressed ) {
 			} else if( settings.inline ) {
 				sb.append( ' ' );
 			} else {
 				indent(sb,indented);
 			}
+		} else if( tbl.isOnlyList() ) {
+			sb.append("nil");
 		}
 		sb.append( '}' );
 		return;