Skip to content

Commit

Permalink
fix(debug): Correctly check location before printing "after" part
Browse files Browse the repository at this point in the history
  • Loading branch information
Darkyenus authored and alerque committed May 21, 2019
1 parent 3a38871 commit a527ea8
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions core/tracestack.lua
Expand Up @@ -61,20 +61,22 @@ local traceStack = {
return afterFrame and "after " .. afterFrame:toLocationString() or nil
end
local info = top:toLocationString()
local locationFrame = top
-- Not all stack traces have to carry location information.
-- If the top stack trace does not carry it, find a frame which does.
-- Then append it, because its information may be useful.
if not top.line then
for i = #traceStack - 1, 1, -1 do
if traceStack[i].line then
-- Found a frame which does carry some relevant information.
info = info .. " near " .. traceStack[i]:toLocationString(--[[skipFile=]] traceStack[i].file == top.file)
locationFrame = traceStack[i]
info = info .. " near " .. locationFrame:toLocationString(--[[skipFile=]] locationFrame.file == top.file)
break
end
end
end
-- Print after, if it is in a relevant file
if afterFrame and (not base or afterFrame.file == base.file) then
if afterFrame and (not locationFrame or afterFrame.file == locationFrame.file) then
info = info .. " after " .. afterFrame:toLocationString(--[[skipFile=]] true)
end
return info
Expand Down

0 comments on commit a527ea8

Please sign in to comment.