mirror of
https://github.com/leafo/moonscript.git
synced 2024-11-22 02:44:23 +00:00
update error rewriters for new @ prefix on chunk name for files
This commit is contained in:
parent
f92e046d13
commit
01555dc4f4
@ -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,
|
||||||
|
@ -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, ":"
|
||||||
|
@ -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 = {
|
||||||
|
Loading…
Reference in New Issue
Block a user