Skip to content

Commit

Permalink
Implement showing LISP traceback on error. #48
Browse files Browse the repository at this point in the history
  • Loading branch information
meric committed Sep 28, 2016
1 parent 010ede1 commit 40048c4
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
3 changes: 1 addition & 2 deletions l2l/compiler.lua
Expand Up @@ -70,8 +70,7 @@ local function record(invariant, data, exp)
exp:match(lua.lua_name, function(value)
return value == lua.lua_name("...")
end))) then
local position, rest = table.unpack(invariant.index[data])
local src = invariant.source:sub(position, rest)
local position, rest = unpack(invariant.index[data])
return lua.lua_paren_exp.new(
lua.lua_functioncall.new(lua.lua_name("trace"),
lua.lua_args.new(lua.lua_explist({
Expand Down
5 changes: 3 additions & 2 deletions l2l/exception.lua
Expand Up @@ -92,8 +92,9 @@ end
local function formatsource(src, index, to)
local messages = {}
local linenumber = numberat(src, index)
local line, start, _ = lineat(src, index)
local _, __, finish = lineat(src, to)
local _, start, _ = lineat(src, index)
local _, _, finish = lineat(src, to)
local line

local columnnumber = index - start + 1

Expand Down
3 changes: 2 additions & 1 deletion l2l/trace.lua
@@ -1,4 +1,5 @@
local unpack = _G["unpack"] or table.unpack
local pack = table.pack or function(...) return {n=select("#", ...), ...} end
local len = require("l2l.len")

local level = setmetatable({
Expand Down Expand Up @@ -40,7 +41,7 @@ local level = setmetatable({
})

return function (exception, f, ...)
local returns = table.pack(pcall(f, ...))
local returns = pack(pcall(f, ...))
local ok = returns[1]
if ok then
return unpack(returns, 2, returns.n)
Expand Down

0 comments on commit 40048c4

Please sign in to comment.