Assert { cond :: Expr, body :: Expr }
| Field | Type | Description |
cond | Expr | Condition that must evaluate to true |
body | Expr | Expression to evaluate if assertion passes |
# Nix
assert x > 0; x + 1
# AST
{
"tag": "Assert",
"cond": {
"tag": "Binary",
"op": ">",
"left": { "tag": "Sym", "contents": "x" },
"right": { "tag": "Constant", "contents": { "tag": "Int", "contents": 0 } }
},
"body": {
"tag": "Binary",
"op": "+",
"left": { "tag": "Sym", "contents": "x" },
"right": { "tag": "Constant", "contents": { "tag": "Int", "contents": 1 } }
}
}
syntax.mkAssert cond body