update error rewriters for new @ prefix on chunk name for files

This commit is contained in:
leaf corcoran 2014-06-07 11:09:50 -07:00
parent f92e046d13
commit 01555dc4f4
3 changed files with 6 additions and 7 deletions

View File

@ -78,8 +78,8 @@ rewrite_traceback = function(text, err)
local cache = { } local cache = { }
local rewrite_single local rewrite_single
rewrite_single = function(trace) rewrite_single = function(trace)
local fname, line, msg = trace:match('^%[string "(.-)"]:(%d+): (.*)$') local fname, line, msg = trace:match('^(.-):(%d+): (.*)$')
local tbl = line_tables[fname] local tbl = line_tables["@" .. tostring(fname)]
if fname and tbl then if fname and tbl then
return concat({ return concat({
fname, fname,

View File

@ -56,8 +56,8 @@ rewrite_traceback = (text, err) ->
cache = {} -- loaded file cache cache = {} -- loaded file cache
rewrite_single = (trace) -> rewrite_single = (trace) ->
fname, line, msg = trace\match '^%[string "(.-)"]:(%d+): (.*)$' fname, line, msg = trace\match '^(.-):(%d+): (.*)$'
tbl = line_tables[fname] tbl = line_tables["@#{fname}"]
if fname and tbl if fname and tbl
concat { concat {
fname, ":" fname, ":"

View File

@ -12,12 +12,11 @@ get_rewritten_line_no = (fname) ->
success, err = pcall chunk success, err = pcall chunk
error "`#{fname}` is supposed to have runtime error!" if success error "`#{fname}` is supposed to have runtime error!" if success
source = tonumber err\match "]:(%d+)" source = tonumber err\match "^.-:(%d+):"
line_table = require("moonscript.line_tables")[fname] line_table = assert require("moonscript.line_tables")["@#{fname}"], "missing line table"
errors.reverse_line_number fname, line_table, source, {} errors.reverse_line_number fname, line_table, source, {}
-- TODO: check entire stack trace -- TODO: check entire stack trace
describe "error rewriting", -> describe "error rewriting", ->
tests = { tests = {