summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Maw <richard.maw@codethink.co.uk>2015-11-26 15:55:01 +0000
committerRichard Maw <richard.maw@codethink.co.uk>2015-11-27 17:46:53 +0000
commit0b254cbed3e683974915792ec76e47523d7a473b (patch)
tree4bbca3f8178a2bd8e0edbc0157d4cd273a86d4f9
parent004b1b907d18b6cc0fe949f35c02dddeb9906c9d (diff)
downloadlace-0b254cbed3e683974915792ec76e47523d7a473b.tar.gz
lace.error: Move augmented source location into words
The intention is to make `words` record which source line the words were in, so it's no longer implicitly the line being interpreted.
-rw-r--r--lib/lace/error.lua8
-rw-r--r--test/test-lace.error.lua4
2 files changed, 6 insertions, 6 deletions
diff --git a/lib/lace/error.lua b/lib/lace/error.lua
index 0ad0df6..2dc7cdb 100644
--- a/lib/lace/error.lua
+++ b/lib/lace/error.lua
@@ -71,8 +71,8 @@ end
-- @treturn table The error table (mutated with the source information).
-- @function augment
local function _augment(err, source, linenr)
- err.source = source
- err.linenr = linenr
+ err.words.source = source
+ err.words.linenr = linenr
return err
end
@@ -102,9 +102,9 @@ local function _render(err)
-- The first line is the error message
local ret = { err.msg }
-- The second is the source filename and line
- ret[2] = err.source.source .. " :: " .. tostring(err.linenr)
+ ret[2] = err.words.source.source .. " :: " .. tostring(err.words.linenr)
-- The third line is the line of the input
- local srcline = err.source.lines[err.linenr] or {
+ local srcline = err.words.source.lines[err.words.linenr] or {
original = "???", content = { {spos = 1, epos = 3, str = "???"} }
}
ret[3] = srcline.original
diff --git a/test/test-lace.error.lua b/test/test-lace.error.lua
index 6f7d995..a2e09a7 100644
--- a/test/test-lace.error.lua
+++ b/test/test-lace.error.lua
@@ -52,8 +52,8 @@ function suite.error_augmentation()
local src = {}
local aug = error.augment(err, src, 10)
assert(aug == err, "Augmentation should return the error")
- assert(err.source == src, "Augmented errors should contain their source data")
- assert(err.linenr == 10, "Augmented errors should contain their error line")
+ assert(err.words.source == src, "Augmented errors should contain their source data")
+ assert(err.words.linenr == 10, "Augmented errors should contain their error line")
end
function suite.error_render()