Skip to content
This repository has been archived by the owner on Jul 7, 2024. It is now read-only.

Commit

Permalink
Fix stackoverflow in traceback
Browse files Browse the repository at this point in the history
Closes #21
  • Loading branch information
SquidDev committed Feb 3, 2016
1 parent 220fdc7 commit 2971e2e
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions depends/modules/Traceback.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,14 @@ local find = string.find
local lineMapper = {
header = [[
-- Maps
local lineToModule = setmetatable({{lineToModule}}, {
__index = function(t, k)
if k > 1 then return t[k-1] end
local lineToModule = {{lineToModule}}
local getLine(line)
while line >= 0 do
local l = lineToModule[line]
if l then return l end
line = line - 1
end
return -1
})
local moduleStarts = {{moduleStarts}}
local programEnd = {{lastLine}}
Expand All @@ -28,7 +32,7 @@ local lineMapper = {
if line > programEnd then return end
-- convert to module lines
filename = lineToModule[line] or "<?>"
filename = getLine(line) or "<?>"
local newLine = moduleStarts[filename]
if newLine then
line = line - newLine + 1
Expand Down

0 comments on commit 2971e2e

Please sign in to comment.