diff util/debug.lua @ 13925:a4c47203a9eb

various: Do not mutate loop variables as they are treated as const in Lua 5.5 Loop variables are treated as <const> in Lua 5.5 and can't be modified without declaring another local. Ref https://github.com/lua/lua/commit/b2f7b3b79f3117885b265575f6c5dbf934757797
author Kim Alvefur <zash@zash.se>
date Fri, 23 Feb 2024 18:44:13 +0100
parents d10957394a3c
children
line wrap: on
line diff
--- a/util/debug.lua	Tue Aug 05 22:35:01 2025 +0200
+++ b/util/debug.lua	Fri Feb 23 18:44:13 2024 +0100
@@ -145,7 +145,8 @@
 	local last_source_desc;
 
 	local lines = {};
-	for nlevel, current_level in ipairs(levels) do
+	for n, current_level in ipairs(levels) do
+		local nlevel = n-1;
 		local info = current_level.info;
 		local line;
 		local func_type = info.namewhat.." ";
@@ -171,7 +172,6 @@
 			last_source_desc = source_desc;
 			table.insert(lines, "\t "..build_source_boundary_marker(last_source_desc));
 		end
-		nlevel = nlevel-1;
 		table.insert(lines, "\t"..(nlevel==0 and ">" or " ")..getstring(styles.level_num, "("..nlevel..") ")..line);
 		local npadding = (" "):rep(#tostring(nlevel));
 		if current_level.locals then