util.serialization: Separate errors for multiple table references and max depth
authorKim Alvefur <zash@zash.se>
Sat, 27 Oct 2018 12:38:47 +0200
changeset 9568 9a1e2f5f674f
parent 9567 ed0090f8b709
child 9569 dad29508d0f2
util.serialization: Separate errors for multiple table references and max depth
util/serialization.lua
--- 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