aboutsummaryrefslogtreecommitdiff
path: root/lib/core/errors.nom
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2019-03-27 14:38:17 -0700
committerBruce Hill <bruce@bruce-hill.com>2019-03-27 14:38:17 -0700
commit91d1189890fbfa04c731cb3dd4211a8d72017f6a (patch)
tree52b498de89a37f27c18e266af5f5d15417b5b784 /lib/core/errors.nom
parentdfda34254c44f9f8aa16ad556a88ec275ec50a16 (diff)
Fix for inequality assumptions and better error reporting for (assume
$foo.$x) style index assumptions.
Diffstat (limited to 'lib/core/errors.nom')
-rw-r--r--lib/core/errors.nom13
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/core/errors.nom b/lib/core/errors.nom
index d77717d..0b5479d 100644
--- a/lib/core/errors.nom
+++ b/lib/core/errors.nom
@@ -16,6 +16,17 @@ use "core/control_flow"
")
(assume $condition) compiles to:
+ if ($condition.type == "IndexChain"):
+ return Lua ("
+ do -- Assumption:
+ local _thing, _key = \($condition.1 as lua expr), \($condition.2.1 as lua expr)
+ if not _thing[_key] then
+ _key = type_of(_key) == 'Text' and _key:as_lua() or _1_as_text(_key)
+ at_1_fail(\(quote "\($condition.source)"),
+ "Assumption failed: \($condition.1 as nomsu, text) does not have a value for ".._key..".")
+ end
+ end
+ ")
if ($condition.type == "Action"):
when $condition.stub is:
"1 ==":
@@ -47,7 +58,7 @@ use "core/control_flow"
return Lua ("
do -- Assumption:
local _a, _b = \($condition.1 as lua expr), \($condition.3 as lua expr)
- if _a ~= _b then
+ if not (_a \($condition.2) _b) then
_a = type_of(_a) == 'Text' and _a:as_lua() or _1_as_text(_a)
_b = type_of(_b) == 'Text' and _b:as_lua() or _1_as_text(_b)
at_1_fail(\(quote "\($condition.1.source)"),