mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-21 00:47:28 +01:00
Allow "assert foo", not just "assert foo < bar".
This commit is contained in:
1 parent
e2ce9f1b1d
commit
3bdd515e47
3 files changed
+13
-5
No files matched your search
@@ -310,8 +310,15 @@ func (q *checker) bcheckStatement(n *a.Node) error {
|
||||
}
|
||||
|
||||
func (q *checker) bcheckAssert(n *a.Assert) error {
|
||||
// TODO: check, here or elsewhere, that the condition is pure.
|
||||
condition := n.Condition()
|
||||
for _, x := range q.facts {
|
||||
if x.Eq(condition) {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
err := errFailed
|
||||
|
||||
if cv := condition.ConstValue(); cv != nil {
|
||||
if cv.Cmp(one) == 0 {
|
||||
err = nil
|
||||
@@ -325,6 +332,7 @@ func (q *checker) bcheckAssert(n *a.Assert) error {
|
||||
} else if condition.ID0().IsBinaryOp() && condition.ID0().Key() != t.KeyAs {
|
||||
err = q.proveBinaryOp(condition.ID0().Key(), condition.LHS().Expr(), condition.RHS().Expr())
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
if err == errFailed {
|
||||
return fmt.Errorf("check: cannot prove %q", condition.String(q.tm))
|
||||
|
||||
Reference in new issue
Block a user