From d3eba132230c12abad3afababf5b0a76251db2b0 Mon Sep 17 00:00:00 2001 From: Nigel Tao Date: Sat, 20 May 2017 13:30:15 +1000 Subject: [PATCH] Prove "assert true". --- lang/check/bounds.go | 6 +++++- lang/check/check_test.go | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lang/check/bounds.go b/lang/check/bounds.go index e28f87cb..6369c12d 100644 --- a/lang/check/bounds.go +++ b/lang/check/bounds.go @@ -56,7 +56,11 @@ func (q *checker) bcheckStatement(n *a.Node) error { n := n.Assert() condition := n.Condition() err := errFailed - if reasonID := n.Reason(); reasonID != 0 { + if cv := condition.ConstValue(); cv != nil { + if cv.Cmp(one) == 0 { + err = nil + } + } else if reasonID := n.Reason(); reasonID != 0 { if reasonFunc := q.reasonMap[reasonID.Key()]; reasonFunc != nil { err = reasonFunc(q, n) } else { diff --git a/lang/check/check_test.go b/lang/check/check_test.go index 26999b1a..1ac26500 100644 --- a/lang/check/check_test.go +++ b/lang/check/check_test.go @@ -68,6 +68,8 @@ func TestCheck(t *testing.T) { var p i32 var q i32[0:8] + assert true + while p == q, post p != q, {