Changeset

9565:9a1e2f5f674f

util.serialization: Separate errors for multiple table references and max depth
author Kim Alvefur <zash@zash.se>
date Sat, 27 Oct 2018 12:38:47 +0200
parents 9564:ed0090f8b709
children 9566:dad29508d0f2
files util/serialization.lua
diffstat 1 files changed, 5 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/util/serialization.lua	Sat Oct 27 12:17:35 2018 +0200
+++ b/util/serialization.lua	Sat Oct 27 12:38:47 2018 +0200
@@ -128,8 +128,11 @@
 	-- l - position in o of where to insert next token
 	-- d - depth, used for indentation
 	local function serialize_table(t, o, l, d)
-		if o[t] or d > maxdepth then
-			o[l], l = fallback(t, "recursion"), l + 1;
+		if o[t] then
+			o[l], l = fallback(t, "table has multiple references"), l + 1;
+			return l;
+		elseif d > maxdepth then
+			o[l], l = fallback(t, "max table depth reached"), l + 1;
 			return l;
 		end