diff options
author | Daniel Silverstone <dsilvers@digital-scurf.org> | 2015-11-24 17:30:09 +0000 |
---|---|---|
committer | Daniel Silverstone <dsilvers@digital-scurf.org> | 2015-11-24 17:30:09 +0000 |
commit | a6a6ee4f86f354477e4b5d374dba4c4e90d03df6 (patch) | |
tree | 4afdaa2aa73ad8c2a666dacbec8c58a376ee4c67 /lib/lace/builtin.lua | |
parent | 5e6124ea7eb07797e2df2d8ea5aa07e951ed4168 (diff) | |
parent | 0cde41427841ad6f031175e9312f536837e40d35 (diff) | |
download | lace-a6a6ee4f86f354477e4b5d374dba4c4e90d03df6.tar.gz |
Merge branch 'subword-errors' of git://git.gitano.org.uk/personal/richardmaw/lacev1.2
Diffstat (limited to 'lib/lace/builtin.lua')
-rw-r--r-- | lib/lace/builtin.lua | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/lib/lace/builtin.lua b/lib/lace/builtin.lua index 147da6a..b0c7ad1 100644 --- a/lib/lace/builtin.lua +++ b/lib/lace/builtin.lua @@ -35,7 +35,12 @@ local function run_conditions(exec_context, cond, anyof) end local res, msg = engine.test(exec_context, name) if res == nil then - msg.words = {i} + local subwords = msg.words + if subwords and #subwords > 0 then + msg.words = {{nr = i, sub = subwords}} + else + msg.words = {i} + end return nil, msg end if invert then @@ -208,7 +213,15 @@ local function _compile_any_all_of(compcontext, mtype, first, second, ...) end return { - fn = run_conditions, + fn = (function(exec_context, cond, anyof) + local pass, msg = run_conditions(exec_context, cond, anyof) + if pass == nil then + -- Offset error location by anyof/allof word + err.offset(msg, 1) + return nil, msg + end + return pass, msg + end), args = { { first, second, ...}, mtype == "anyof" } } end |