Mercurial > prosody-hg
comparison 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 |
comparison
equal
deleted
inserted
replaced
| 13924:7fdf7645b0da | 13925:a4c47203a9eb |
|---|---|
| 143 local levels = get_traceback_table(thread, level+(thread == nil and 4 or 0)); | 143 local levels = get_traceback_table(thread, level+(thread == nil and 4 or 0)); |
| 144 | 144 |
| 145 local last_source_desc; | 145 local last_source_desc; |
| 146 | 146 |
| 147 local lines = {}; | 147 local lines = {}; |
| 148 for nlevel, current_level in ipairs(levels) do | 148 for n, current_level in ipairs(levels) do |
| 149 local nlevel = n-1; | |
| 149 local info = current_level.info; | 150 local info = current_level.info; |
| 150 local line; | 151 local line; |
| 151 local func_type = info.namewhat.." "; | 152 local func_type = info.namewhat.." "; |
| 152 local source_desc = (info.short_src == "[C]" and "C code") or info.short_src or "Unknown"; | 153 local source_desc = (info.short_src == "[C]" and "C code") or info.short_src or "Unknown"; |
| 153 if func_type == " " then func_type = ""; end; | 154 if func_type == " " then func_type = ""; end; |
| 169 end | 170 end |
| 170 if source_desc ~= last_source_desc then -- Venturing into a new source, add marker for previous | 171 if source_desc ~= last_source_desc then -- Venturing into a new source, add marker for previous |
| 171 last_source_desc = source_desc; | 172 last_source_desc = source_desc; |
| 172 table.insert(lines, "\t "..build_source_boundary_marker(last_source_desc)); | 173 table.insert(lines, "\t "..build_source_boundary_marker(last_source_desc)); |
| 173 end | 174 end |
| 174 nlevel = nlevel-1; | |
| 175 table.insert(lines, "\t"..(nlevel==0 and ">" or " ")..getstring(styles.level_num, "("..nlevel..") ")..line); | 175 table.insert(lines, "\t"..(nlevel==0 and ">" or " ")..getstring(styles.level_num, "("..nlevel..") ")..line); |
| 176 local npadding = (" "):rep(#tostring(nlevel)); | 176 local npadding = (" "):rep(#tostring(nlevel)); |
| 177 if current_level.locals then | 177 if current_level.locals then |
| 178 local locals_str = string_from_var_table(current_level.locals, optimal_line_length, "\t "..npadding); | 178 local locals_str = string_from_var_table(current_level.locals, optimal_line_length, "\t "..npadding); |
| 179 if locals_str then | 179 if locals_str then |
